Tests for device config updates on org variable changes
Checklist
- [x] I have read the OpenWISP Contributing Guidelines.
- [x] I have manually tested the changes proposed in this pull request.
- [x] I have written new test cases for new code and/or updated existing tests for changes to existing code.
- [ ] I have updated the documentation.
Reference to Existing Issue
Closes #1070.
Description of Changes
This PR adds missing automated tests to ensure device configuration status updates correctly when organization configuration variables (context) change. The existing implementation already handled this logic correctly (via checksum comparison) but there was no automated test coverage verifying the behavior.
What’s Added
A new test class TestOrganizationConfigUpdates in openwisp_controller/config/tests/test_device.py. It includes three scenarios:
-
Affected device becomes
modified- Template uses
{{ ssid }} - Changing org context updates config status
- Template uses
-
Unaffected device remains
applied- Template has no variables
- Context change does not affect checksum
-
No status change when checksum does not change
- Unused variable changes
- Config remains unchanged
Notes:
- No production code was modified
- Tests run synchronously (CELERY_TASK_ALWAYS_EAGER=True)
- Ensures future regressions are prevented
Screenshot
Creating a Organization
Creating a Template-1
Creating a Template-2
Device-1 Configuration
Device-2 Configuration
Before Change
Change Org Variable
Device Status Change