Standardize test base class inheritance. Closes #700#714
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request standardizes test base class inheritance across the test suite by ensuring all tests inherit from either CustomTestCase or ExtractionTestCase as defined in tests/__init__.py, addressing inconsistent test inheritance patterns identified in issue #700.
Changes:
- Replaced
SimpleTestCasewithCustomTestCasein ntfy and RF config tests - Replaced
TestCasewithCustomTestCasein serializer tests and updatedsetUpClasstosetUpTestData - Replaced
unittest.TestCasewithExtractionTestCasein cowrie extraction tests andCustomTestCasein monitor logs tests
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_serializers.py | Changed from Django's TestCase to CustomTestCase, migrated setUpClass to setUpTestData with proper super() call, added logic to check for existing adbhoney honeypot |
| tests/test_rf_config.py | Changed from SimpleTestCase to CustomTestCase, reformatted class_weight parameter logic for readability |
| tests/test_ntfy.py | Changed from SimpleTestCase to CustomTestCase, reformatted long function calls for better line length compliance |
| tests/test_cowrie_extraction.py | Changed from unittest.TestCase to ExtractionTestCase, reformatted imports and long lines for style compliance |
| tests/greedybear/cronjobs/test_monitor_logs.py | Changed from unittest.TestCase to CustomTestCase, reformatted long string for better line length compliance |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5e7a4af to
cf5d851
Compare
regulartim
left a comment
There was a problem hiding this comment.
Nice! However you made some minor formatting changes (like splitting up single line commands to multiple lines). I would rather not have them in this PR. Or is there some strong reason for them?
|
Hi @regulartim The extra formatting changes came from running Black.(as mentioned in Contribution guidelines to use linters like blake flake8 and isort. I can make a minimal commit with just the inheritance changes if you'd prefer and undo the unsual formatting. |
|
Hey @RaviTeja799 ! :) We recently switched to Ruff. The contribution guidelines are already updated, but the PR template still mentions the old linters. As I said, I would prefer a PR just with the inheritance changes. |
cf5d851 to
a3d2369
Compare
|
Hi @regulartim! Thanks for the feedback! I've updated the PR with minimal changes as requested - only the import and class inheritance changes. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
tests/test_cowrie_extraction.py:85
- The setUp method should call super().setUp() to ensure proper initialization of the parent ExtractionTestCase class. While the current code works because it's recreating the same mock objects, not calling super() could lead to issues if the parent class setUp is extended in the future.
def setUp(self):
"""Set up test fixtures."""
self.mock_ioc_repo = Mock()
self.mock_sensor_repo = Mock()
self.mock_session_repo = Mock()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hey @RaviTeja799 ! Looks good now, thanks for your work! |
Description
Standardized all tests to inherit from CustomTestCase or ExtractionTestCase as defined in tests/init.py, addressing the inconsistent inheritance pattern across the test suite.
Changes Made
SimpleTestCaseto CustomTestCase in test_ntfy.py and test_rf_config.pysetUpClass→ setUpTestData with propersuper()call)unittest.TestCaseto ExtractionTestCase in test_cowrie_extraction.pyunittest.TestCaseto CustomTestCase in test_monitor_logs.pyRelated issues
Closes #700
Type of change
Checklist
develop.Black,Flake,Isort) gave 0 errors.