Skip to content
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

Unittest for bgp_peers compare_snapshots fails occasionally #166

Closed
alperenkose opened this issue Apr 4, 2024 · 1 comment
Closed

Unittest for bgp_peers compare_snapshots fails occasionally #166

alperenkose opened this issue Apr 4, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@alperenkose
Copy link
Collaborator

Describe the bug

test_compare_snapshots unittest for "bgp_peers" fail occasionally. The bgp_peers snapshot have multiple levels which we don't support in snapshot comparison currently. When comparison snapshots it randomly finds out the lowest level of the dictionary and when snapshot have multiple levels provided properties isn't found and comparison shows diff for all the dictionary instead of only the requested properties.

Current behavior

Need to run unittest multiple times since it randomly gets into different levels of the dict.

> pytest -k test_compare_snapshots
    def test_compare_snapshots(self, reports, expected_result):
        snapshot_compare = SnapshotCompare(snap1, snap2)
        result = snapshot_compare.compare_snapshots(reports)

>       assert not DeepDiff(
            result, expected_result, ignore_order=True
        )  # assert == doesnt work for nested objects and unordered lists
E       AssertionError: assert not {'dictionary_item_removed': [root['bgp_peers']['changed']['changed_raw']['default_Peer-Group1_Peer1']['changed']['chan...out'], root['bgp_peers']['changed']['changed_raw']['default_Peer-Group1_Peer1']['changed']['changed_raw']['holdtime']]}
E        +  where {'dictionary_item_removed': [root['bgp_peers']['changed']['changed_raw']['default_Peer-Group1_Peer1']['changed']['chan...out'], root['bgp_peers']['changed']['changed_raw']['default_Peer-Group1_Peer1']['changed']['changed_raw']['holdtime']]} = DeepDiff({'bgp_peers': {'added': {'added_keys': [], 'passed': True}, 'changed': {'changed_raw': {'default_Peer-Group1_Peer1': {...passed': True}, 'passed': False}}, 'passed': False}, 'missing': {'missing_keys': [], 'passed': True}, 'passed': False}}, {'bgp_peers': {'added': {'added_keys': [], 'passed': True}, 'changed': {'changed_raw': {'default_Peer-Group1_Peer1': {...passed': True}, 'passed': False}}, 'passed': False}, 'missing': {'missing_keys': [], 'passed': True}, 'passed': False}}, ignore_order=True)

tests/test_snapshot_compare.py:477: AssertionError
============================================================================================= short test summary info =============================================================================================
FAILED tests/test_snapshot_compare.py::TestSnapshotCompare::test_compare_snapshots[reports4-expected_result4] - AssertionError: assert not {'dictionary_item_removed': [root['bgp_peers']['changed']['changed_raw']['default_Peer-Group1_Peer1']['changed']['chan...out'], root['bgp_peers']['changed']['changed_raw']['defaul...
=================================================================================== 1 failed, 6 passed, 280 deselected in 0.25s ===================================================================================

Possible solution

Related to issue #108 - which will be fixed.

@alperenkose alperenkose added the bug Something isn't working label Apr 4, 2024
@alperenkose
Copy link
Collaborator Author

Fixed by #128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant