Skip to content

Split test_repositories.py into separate files for better maintainability. Closes #703#704

Merged
regulartim merged 2 commits intointelowlproject:developfrom
opbot-xd:split-test-repositories
Jan 13, 2026
Merged

Split test_repositories.py into separate files for better maintainability. Closes #703#704
regulartim merged 2 commits intointelowlproject:developfrom
opbot-xd:split-test-repositories

Conversation

@opbot-xd
Copy link
Copy Markdown
Contributor

Description

This PR splits the monolithic test_repositories.py file (1,111 lines) into 6 separate, focused test files - one for each repository class. This improves code maintainability, navigation, and scalability as the test suite grows.

Files created:

  • test_ioc_repository.py (561 lines): IOC and scoring tests
  • test_sensor_repository.py (58 lines): Sensor tests
  • test_cowrie_session_repository.py (175 lines): Cowrie session tests
  • test_elastic_repository.py (224 lines): Elasticsearch tests
  • test_firehol_repository.py (39 lines): FireHol tests
  • test_mass_scanner_repository.py (37 lines): Mass scanner tests

Test verification:

  • All 101 tests pass successfully in 3.365s
  • No test logic modified, only file organization
  • Pre-commit hooks (Ruff lint & format) passed

Related issues

Closes #703

Type of change

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist

  • I have read and understood the rules about how to Contribute to this project.
  • The pull request is for the branch develop.
  • I have added documentation of the new features.
  • Linter (Ruff) gave 0 errors. If you have correctly installed pre-commit, it does these checks and adjustments on your behalf.
  • I have added tests for the feature/bug I solved. All the tests (new and old ones) gave 0 errors.
  • If changes were made to an existing model/serializer/view, the docs were updated and regenerated (check CONTRIBUTE.md).
  • If the GUI has been modified:
    • I have a provided a screenshot of the result in the PR.
    • I have created new frontend tests for the new component or updated existing ones.

- Split 1111-line test_repositories.py into 6 focused test files
- test_ioc_repository.py (561 lines): IOC and scoring tests
- test_sensor_repository.py (58 lines): Sensor tests
- test_cowrie_session_repository.py (175 lines): Cowrie session tests
- test_elastic_repository.py (224 lines): Elasticsearch tests
- test_firehol_repository.py (39 lines): FireHol tests
- test_mass_scanner_repository.py (37 lines): Mass scanner tests
- All 101 tests pass successfully
- Improved maintainability and navigation
Copilot AI review requested due to automatic review settings January 13, 2026 15:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the test suite by splitting a monolithic 1,111-line test_repositories.py file into 6 focused test files, each dedicated to testing a specific repository class. This is a pure code organization change with no modifications to test logic.

Changes:

  • Deleted the original test_repositories.py file containing all repository tests
  • Created 6 new test files, each focusing on a single repository class with appropriate imports
  • Maintained all 101 tests with identical logic and behavior

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_repositories.py Removed monolithic file containing all repository tests (1,111 lines)
tests/test_ioc_repository.py Added IOC repository tests including scoring integration and cleanup tests (561 lines)
tests/test_sensor_repository.py Added sensor repository tests for IP address validation and caching (58 lines)
tests/test_cowrie_session_repository.py Added Cowrie session repository tests including cleanup methods (175 lines)
tests/test_elastic_repository.py Added Elasticsearch repository tests and time window calculation tests (224 lines)
tests/test_firehol_repository.py Added FireHol repository tests for blocklist management (39 lines)
tests/test_mass_scanner_repository.py Added mass scanner repository tests (37 lines)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

self.repo._honeypot_cache.clear()
hp = self.repo.create_honeypot("UniqueNewPot123")
self.assertEqual(hp.name, "UniqueNewPot123")
self.assertTrue("uniquenewpot123" in self.repo._honeypot_cache)
Copy link

Copilot AI Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertTrue(a in b) cannot provide an informative message. Using assertIn(a, b) instead will give more informative messages.

Suggested change
self.assertTrue("uniquenewpot123" in self.repo._honeypot_cache)
self.assertIn("uniquenewpot123", self.repo._honeypot_cache)

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to accept or ignore this. As you like. @opbot-xd

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion You're absolutely right - assertIn provides much better error messages than assertTrue(x in y).

I've applied the change and pushed the update. The assertion now reads:

self.assertIn("uniquenewpot123", self.repo._honeypot_cache)

Applied Copilot suggestion to improve test assertion readability.
Replace assertTrue(x in y) with assertIn(x, y) for more informative
error messages when tests fail.
@opbot-xd opbot-xd requested a review from regulartim January 13, 2026 16:25
@regulartim regulartim merged commit 85b6948 into intelowlproject:develop Jan 13, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants