Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Commit

Permalink
fix: deepdiff should ignore order of list attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
trgiangdo committed Oct 16, 2023
1 parent 4c348ba commit e61c490
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/taipy/config/_config_comparator/_config_comparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __get_config_diff(self, config_1, config_2):
json_config_1 = json.loads(_JsonSerializer._serialize(config_1))
json_config_2 = json.loads(_JsonSerializer._serialize(config_2))

config_deepdiff = DeepDiff(json_config_1, json_config_2)
config_deepdiff = DeepDiff(json_config_1, json_config_2, ignore_order=True)

comparator_result = _ComparatorResult(copy(self._unconflicted_sections))

Expand Down
18 changes: 16 additions & 2 deletions tests/config/test_config_comparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ class TestConfigComparator:
section_1 = SectionForTest("section_1", attribute="attribute_1", prop="prop_1")
section_2 = SectionForTest("section_2", attribute=2, prop="prop_2")
section_2b = SectionForTest("section_2", attribute="attribute_2", prop="prop_2b")
section_3 = SectionForTest("section_5", attribute=[1, 2, 3, 4], prop=["prop_1"])
section_3b = SectionForTest("section_5", attribute=[1, 2], prop=["prop_1", "prop_2", "prop_3"])
section_3 = SectionForTest("section_3", attribute=[1, 2, 3, 4], prop=["prop_1"])
section_3b = SectionForTest("section_3", attribute=[1, 2], prop=["prop_1", "prop_2", "prop_3"])
section_3c = SectionForTest("section_3", attribute=[2, 1], prop=["prop_3", "prop_1", "prop_2"])

def test_comparator_compare_method_call(self):
_config_1 = _Config._default_config()
Expand Down Expand Up @@ -176,6 +177,19 @@ def test_comparator_with_modified_list_attribute(self):
assert conflicted_config_diff.get("removed_items") is None
assert conflicted_config_diff.get("added_items") is None

def test_comparator_with_different_order_list_attributes(self):
_config_1 = _Config._default_config()
_config_1._unique_sections
_config_1._sections[SectionForTest.name] = {"section_3": self.section_3b}

# Create _config_2 with different order of list attributes
_config_2 = _Config._default_config()
_config_2._sections[SectionForTest.name] = {"section_3": self.section_3c}
config_diff = Config._comparator._find_conflict_config(_config_1, _config_2)

# There should be no difference since the order of list attributes is ignored
assert config_diff == {}

def test_comparator_with_new_unique_section(self):
_config_1 = _Config._default_config()

Expand Down

0 comments on commit e61c490

Please sign in to comment.