-
Notifications
You must be signed in to change notification settings - Fork 31
Fixes #47 [Housekeeping]: Develop Plugin Tests - Models #257
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: dev
Are you sure you want to change the base?
Fixes #47 [Housekeeping]: Develop Plugin Tests - Models #257
Conversation
Renames `test_models.py` to `models/test_accesslists.py` to improve test organization and maintainability. This is a structural change with no modifications to test logic.
Refactor test setup to improve data creation and reusability. Add detailed fixtures for devices, virtual chassis, clusters, virtual machines, and prefixes. Update all assignments to reference the new fixtures for better consistency.
Add test cases to validate AccessList creation and uniqueness for VirtualChassis and VirtualMachine objects. Extend coverage by ensuring proper handling of duplicate names and enforcing unique constraints.
Note: This is a draft PR. I rebased the work by @ryanmerolle from PR #134, cleaned up the codebase, and added additional tests. I'll be adding tests for ACLStandardRule and ACLExtendedRule in the coming days. |
Introduces internationalization (i18n) to AccessList models. Updates field definitions to use `gettext_lazy` for translations and improves model class field consistency. Includes minor corrections to docstrings and comments.
Move validation to the `save` method to enforce that the assigned interface's host matches the access list's host before saving. This replaces validation in the `clean` method for better data integrity enforcement.
Improve test coverage for ACLInterfaceAssignment validation. Add tests for valid and invalid direction choices, duplicate assignments, and missing host assignments to ensure robust validation logic.
Fixes the unique constraint for ACLInterfaceAssignment by removing the access_list field from the uniqueness check. Ensures that only one ACL can be assigned per interface and direction. Adds validation tests to prevent multiple ACLs from being assigned in the same direction on the same interface. Fixes netbox-community#258
Moves ACL rule validation logic from forms to model methods to ensure consistent enforcement across all usages. This improves maintainability and eliminates redundant validation code.
Adds comprehensive tests for the ACLStandardRule model. Tests cover rule creation scenarios, validation constraints, and edge cases, ensuring thorough model behavior validation. Fixes netbox-community#47
5fb926c
to
dc69c16
Compare
Introduces comprehensive test cases for the ACLExtendedRule model. These cover rule creation, validation, and edge cases such as duplicate indices and invalid combinations of parameters. Fixes netbox-community#47
dc69c16
to
a872eea
Compare
I included a fix for Bug #258, as it was necessary to properly test the uniqueness of Interface and Direction. Additionally, I cleaned up the model files I appreciate your time reviewing all these changes. Thank you, @cruse1977 ! |
Pull Request
Related Issue
Fixes: #47 [Housekeeping] Develop Plugin Tests - Models
Fixes #258 [Bug] ACL Interface Assignment Should Be Unique per Interface and Direction
New Behavior
Contrast to Current Behavior
Discussion: Benefits and Drawbacks
Changes to the Documentation
Proposed Release Note Entry
Attribution
Some of the code in this PR is based on previous work by @ryanmerolle in PR #134.
Double Check
or in a linked issue.
dev
branch.