openwisp-controller icon indicating copy to clipboard operation
openwisp-controller copied to clipboard

Tests for device config updates on org variable changes

Open ssmadhavan006 opened this issue 3 weeks ago • 0 comments

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:

  1. Affected device becomes modified

    • Template uses {{ ssid }}
    • Changing org context updates config status
  2. Unaffected device remains applied

    • Template has no variables
    • Context change does not affect checksum
  3. 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 Screenshot 2025-12-08 232106

Creating a Template-1 Screenshot 2025-12-08 230936 Screenshot 2025-12-08 230943

Creating a Template-2 Screenshot 2025-12-08 231012 Screenshot 2025-12-08 231022

Device-1 Configuration Screenshot 2025-12-08 231631

Device-2 Configuration Screenshot 2025-12-08 231644

Before Change Screenshot 2025-12-08 231402

Change Org Variable Screenshot 2025-12-08 232038

Device Status Change Screenshot 2025-12-08 231518

ssmadhavan006 avatar Dec 08 '25 18:12 ssmadhavan006