-
Notifications
You must be signed in to change notification settings - Fork 8
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
fix: calculate_diff_on_dicts to Support Integer Values for ARP Table ttl #153
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cdot65 one of the unittest is failing where we were testing for the WrongDataTypeException
is being raised because "int" is a valid value now.
I would do that but since it's from a fork branch, could you please update the following unittest in test_snapshot_compare.py
with a non-valid input like below with a float perhaps (12.3
instead of 123
)?
def test_calculate_diff_on_dicts_invalid_input(self):
left_snapshot = {"key1": 12.3, "key2": "value2"}
right_snapshot = {"key1": {"nested_key1": "value1"}, "key2": "value2"}
with pytest.raises(WrongDataTypeException) as exception_msg:
SnapshotCompare.calculate_diff_on_dicts(left_snapshot, right_snapshot)
assert str(exception_msg.value) == "Unknown value format for key key1."
@alperenkose whats up with the unit tests job in the pipeline? Something weird:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@adambaumeister I'm working on fixing this. Actually the root cause is that "write" access in github actions is not allowed from fork repo PRs. I was investigating it on how to securely allow commenting unittests coverage results on fork repo PRs and found a solution. I will open a separate PR for that. |
## [0.3.4](v0.3.3...v0.3.4) (2024-03-07) ### Features * bgp peers snapshot comparison ([#154](#154)) ([4fec622](4fec622)) ### Bug Fixes * calculate_diff_on_dicts to Support Integer Values for ARP Table ttl ([#153](#153)) ([47ebea5](47ebea5)) * **firewall_proxy/is_panorama_connected:** Added fix for panorama check for FWs in version PAN-OS 11 or later ([#159](#159)) ([e617dbc](e617dbc)) * route snapshot missing entries fix ([#146](#146)) ([d946462](d946462))
🎉 This PR is included in version 0.3.4 🎉 The release is available on PyPI and GitHub release
|
Description
This PR addresses an issue encountered when comparing ARP tables using the
calculate_diff_on_dicts
function, specifically whenttl
values are present as integers. Previously, the function would raise aWrongDataTypeException
due to its inability to handle integer values, causing failures in scripts that rely on comparing ARP table entries.Addresses #152
Motivation and Context
The
calculate_diff_on_dicts
function was limited to handling strings and dictionaries, overlooking the possibility of integer values such as those found inttl
fields of ARP tables. This limitation led to aWrongDataTypeException
when the function encountered an integerttl
value, particularly evident when comparing ARP tables with single entries.To resolve this issue, the comparison logic within
calculate_diff_on_dicts
has been extended to include integer values. The updated logic now checks for both strings and integers, allowing for a successful comparison ofttl
values without raising exceptions. The specific change involved modifying the conditional check to:How Has This Been Tested?
I tested the changes extensively in a controlled environment to ensure that the updated
calculate_diff_on_dicts
function now correctly handles ARP tables with integerttl
values. Specifically, I performed the following tests:ttl
values.calculate_diff_on_dicts
function to compare two ARP tables: one before the change and one with the updatedttl
handling.WrongDataTypeException
and accurately reflects the differences in ARP entries.Testing Environment:
These tests confirmed that the function now performs as expected, enabling accurate comparison of ARP tables, including those with integer
ttl
values, without any errors.Types of changes
Checklist