Skip to content

test: add unit tests for NERService (Fixes #440)#897

Open
zeroknowledge0x wants to merge 1 commit into
ritesh-1918:mainfrom
zeroknowledge0x:test/ner-service-unit-tests
Open

test: add unit tests for NERService (Fixes #440)#897
zeroknowledge0x wants to merge 1 commit into
ritesh-1918:mainfrom
zeroknowledge0x:test/ner-service-unit-tests

Conversation

@zeroknowledge0x
Copy link
Copy Markdown

Fixes #440

Summary

Adds unit tests for NERService in backend/services/ner_service.py. All 17 tests pass with ML dependencies mocked.

Changes

  • Created backend/tests/test_ner_service.py with 17 test cases
  • Tests _clean_label(): O tag, B-B-, I-B-, B-, I- prefixes, unknown labels
  • Tests REGEX_PATTERNS: IP address, hostname, network error, VLAN, database, browser
  • Tests extract_entities(): empty text handling, regex fallback for IP addresses
  • Tests load(): idempotency, missing model error
  • All heavy dependencies mocked (torch, transformers)

Testing

python -m pytest backend/tests/test_ner_service.py -v --noconftest

Result: 17 passed in 0.26s

Test Coverage

Category Tests Description
Init 1 Default state
_clean_label 6 O, B-B-, I-B-, B-, I-, unknown
REGEX_PATTERNS 6 IP, hostname, network error, VLAN, database, browser
extract_entities 2 Empty text, regex IP fallback
load 2 Idempotent, missing model

- 17 tests covering initialization, _clean_label parsing, regex patterns,
  extract_entities, and load behavior
- Tests verify: BIO tag parsing, regex fallback for IP/hostname/VLAN/etc,
  empty text handling, load idempotency, missing model error
- All ML dependencies mocked (torch, transformers)
@vercel
Copy link
Copy Markdown

vercel Bot commented May 31, 2026

@zeroknowledge0x is attempting to deploy a commit to the ritesh Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 31, 2026

Warning

Review limit reached

@zeroknowledge0x, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 26 minutes and 34 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bb02e820-8048-4bbe-a4c4-55a93ccce93d

📥 Commits

Reviewing files that changed from the base of the PR and between da8faf2 and 7636425.

📒 Files selected for processing (1)
  • backend/tests/test_ner_service.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ritesh-1918
Copy link
Copy Markdown
Owner

Hi @zeroknowledge0x! 🙌

Thank you so much for your excellent contribution: "test: add unit tests for NERService (Fixes #440)"! We really appreciate the high-quality code and effort you have put into the platform.

Just a quick, friendly heads-up as we prepare our manual merging and verification queues—please make sure to complete all the mandatory community steps listed below.

Once those manual steps are verified, we'll get your PR officially merged into the gssoc branch (or keep it neatly cataloged if closed as integrated) and assign it the highest possible GSSoC S-Tier labels to maximize your leaderboard points!

Let's build something amazing together! 🚀🔥


🌟 Community Support & Network Steps (Take 10 Seconds!)

As we prepare our manual verification and merging queues, please make sure you have taken a moment to complete these required steps to finalize your points:

  1. Star this repository: https://github.com/ritesh-1918/HELPDESK.AI (Mandatory)
  2. 🍴 Fork this repository: https://github.com/ritesh-1918/HELPDESK.AI/fork (Mandatory)
  3. 👤 Follow @ritesh-1918 on GitHub: https://github.com/ritesh-1918 (Mandatory - manual step)
  4. 💼 Connect on LinkedIn: https://www.linkedin.com/in/ritesh1908/ (Mandatory)

Note: Having these steps completed manually is required before your PR points are officially cleared.

@ritesh-1918 ritesh-1918 added gssoc GirlScript Summer of Code gssoc:approved GSSoC Approved PR quality:exceptional Exceptional code quality level:critical Critical level difficulty type:testing Testing suites, mock coverages, CI/CD integrations labels May 31, 2026
@ritesh-1918
Copy link
Copy Markdown
Owner

Hi @zeroknowledge0x! 🙌

Thank you so much for your excellent contribution: "test: add unit tests for NERService (Fixes #440)"! We really appreciate the high-quality code and effort you have put into the platform.

Just a quick, friendly heads-up as we prepare our manual merging and verification queues—please make sure to complete all the mandatory community steps listed below.

Once those manual steps are verified, we'll get your PR officially merged into the gssoc branch (or keep it neatly cataloged if closed as integrated) and assign it the highest possible GSSoC S-Tier labels to maximize your leaderboard points!

Let's build something amazing together! 🚀🔥


🌟 Community Support & Network Steps (Take 10 Seconds!)

As we prepare our manual verification and merging queues, please make sure you have taken a moment to complete these required steps to finalize your points:

  1. Star this repository: https://github.com/ritesh-1918/HELPDESK.AI (Mandatory)
  2. 🍴 Fork this repository: https://github.com/ritesh-1918/HELPDESK.AI/fork (Mandatory)
  3. 👤 Follow @ritesh-1918 on GitHub: https://github.com/ritesh-1918 (Mandatory - manual step)
  4. 💼 Connect on LinkedIn: https://www.linkedin.com/in/ritesh1908/ (Mandatory)

Note: Having these steps completed manually is required before your PR points are officially cleared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC Approved PR gssoc GirlScript Summer of Code level:critical Critical level difficulty quality:exceptional Exceptional code quality type:testing Testing suites, mock coverages, CI/CD integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test : add unit tests for ner_service

2 participants