-
-
Notifications
You must be signed in to change notification settings - Fork 45
Refactor Message class #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: min-devel
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 Message class to improve maintainability and testability by introducing a configuration dataclass, extracting database operations into a repository pattern, enhancing error handling, and renaming methods for clarity.
- Introduced
MessageConfigurationdataclass to encapsulate configuration options - Extracted database operations into
AccountRepositoryabstraction - Renamed private methods to use descriptive names and added comprehensive try/except error handling
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 15 comments.
| File | Description |
|---|---|
| acme_srv/message.py | Implements the main refactoring with new MessageConfiguration dataclass, AccountRepository class, method renaming, and enhanced error handling with try/except blocks |
| test/test_message.py | Updates test suite to use new configuration object structure (config.property_name), new method names, and repository pattern (repo instead of dbstore) |
Comments suppressed due to low confidence (1)
acme_srv/message.py:287
- The debug log statement is incorrectly placed inside the if block at line 285, which only executes when code is 200 and signature check is not skipped. This should be outside all conditional blocks to log the function exit in all cases, ensuring consistent debugging output regardless of the code path taken.
account_name, content, use_emb_key, protected
)
if sig_check:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
test/test_message.py
Outdated
| self.message.eab_handler = eab_handler_module.EABhandler | ||
| self.message.eab_handler.mac_key_get = MagicMock(return_value="mac_key") |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test is setting self.message.eab_handler (line 748) but the refactored code expects the eab_handler to be in self.message.config.eab_handler. This test will not work correctly and needs to be updated to use self.message.config.eab_handler instead.
| self.message.eab_handler = eab_handler_module.EABhandler | |
| self.message.eab_handler.mac_key_get = MagicMock(return_value="mac_key") | |
| self.message.config.eab_handler = eab_handler_module.EABhandler | |
| self.message.config.eab_handler.mac_key_get = MagicMock(return_value="mac_key") |
This PR introduces a major refactor of the Message class and its related test suite. The changes focus on improving maintainability, testability, and clarity, while preserving all public interfaces and backward compatibility.
The Message class now delegates all account and permission lookups/updates to this repository.
Error messages and log statements have been standardized for easier debugging and monitoring.