forked from datafold/data-diff
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DBE-3085 removed data-check.py and added test_stop_at_top_level.py
- Loading branch information
ChaosHour
authored and
ChaosHour
committed
Dec 17, 2024
1 parent
c423027
commit 60d060f
Showing
2 changed files
with
38 additions
and
38 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import pytest | ||
from data_diff.hashdiff_tables import HashDiffer | ||
|
||
def test_stop_at_top_level(): | ||
differ = HashDiffer(stop_at_top_level=True) | ||
# Test data with nested structures | ||
data1 = [ | ||
{"top1": {"nested": "value1"}, | ||
"top2": {"nested": "value2"}} | ||
] | ||
data2 = [ | ||
{"top1": {"nested": "changed1"}, | ||
"top2": {"nested": "value2"}} | ||
] | ||
|
||
# Test without stop_at_top_level | ||
differ.stop_at_top_level = False | ||
full_diff = differ.diff_tables(data1, data2) | ||
assert any("nested" in str(d) for d in full_diff) | ||
|
||
# Test with stop_at_top_level | ||
differ.stop_at_top_level = True | ||
top_level_diff = differ.diff_tables(data1, data2) | ||
assert any("top1" in str(d) for d in top_level_diff) | ||
assert not any("nested" in str(d) for d in top_level_diff) | ||
|
||
def test_stop_at_top_level_equal_nested(): | ||
differ = HashDiffer(stop_at_top_level=True) | ||
# Test case where nested values are equal | ||
data1 = [ | ||
{"top": {"nested": "same"}} | ||
] | ||
data2 = [ | ||
{"top": {"nested": "same"}} | ||
] | ||
|
||
diff = differ.diff_tables(data1, data2) | ||
assert len(diff) == 0 # Should show no differences |