Skip to content

Conversation

pheus
Copy link
Contributor

@pheus pheus commented May 17, 2025

Pull Request

Related Issue

Fixes: #131 [Housekeeping] Develop Plugin Tests – API

New Behavior

  • Adds and improves API view tests for the NetBox ACLs plugin.
  • Introduces comprehensive tests for:
    • AccessList API views (including device and virtual machine targets).
    • ACLInterfaceAssignment API views.
    • ACLStandardRule and ACLExtendedRule API views.
  • Improves test structure by splitting test cases into dedicated modules under the api/ test directory.

Contrast to Current Behavior

  • Previously, all API tests were located in a single, flat file (test_api.py) with limited coverage.
  • Now tests are modularized, easier to maintain, and offer broader coverage of plugin functionality.
  • Additional cases now test objects like virtual machines and ensure direction/assignment logic behaves correctly.

Discussion: Benefits and Drawbacks

Benefits:

  • Improves test coverage, ensuring plugin behavior is validated across different models and conditions.
  • Boosts maintainability through improved file structure and simplified test data setup.
  • Provides a solid foundation for future API changes or enhancements.

Drawbacks:

  • None significant. No functional or runtime changes—only test-related improvements.

Fully isolated to test files.

Changes to the Documentation

  • No changes required. These updates apply strictly to internal test coverage.

Proposed Release Note Entry

  • Restructured and expanded API test coverage for Access Lists and Interface Assignments.

Double Check

  • I have explained my PR according to the information in the comments
    or in a linked issue.
  • My PR targets the dev branch.

pheus added 5 commits May 17, 2025 09:41
Renames `test_api.py` to `api/test_accesslists.py` to improve test
organization and maintainability. This is a structural change
with no modifications to test logic.
Moved `AppTest` class to a separate file `test_app.py` for better
organization. Simplified imports by removing unused dependencies in
`test_access_lists.py`.
Refactors and extends AccessList API view test cases. Adds support for
testing virtual machines and improves test data setup by using
`assigned_object` directly instead of separate fields for object type
and ID.
Introduces tests for ACLInterfaceAssignment API views. Covers device and
virtual machine interfaces with various ACL directions and assignments,
ensuring comprehensive test coverage for API behavior.
Introduces comprehensive tests for ACLStandardRule and ACLExtendedRule
API views to ensure functionality and correctness. Adds setup data
and permissions for both standard and extended ACL rule types.
@cruse1977 cruse1977 merged commit cc38ad2 into netbox-community:dev Jul 9, 2025
6 checks passed
@pheus pheus deleted the housekeeping/131-develop-plugin-tests-api branch July 9, 2025 20:24
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.

[Housekeeping]: Develop Plugin Tests - API
2 participants