From 2a86ba0e49719e0d1ab9ff3fb8ad3a34a8953493 Mon Sep 17 00:00:00 2001 From: Jarno Westhof Date: Tue, 14 Nov 2023 23:07:10 +0100 Subject: [PATCH 1/3] Actually print the different in the duplicated ids check --- test/general/test_ids.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/test/general/test_ids.py b/test/general/test_ids.py index 4edfb8d994ef..1551b03595e4 100644 --- a/test/general/test_ids.py +++ b/test/general/test_ids.py @@ -59,10 +59,27 @@ def test_duplicate_item_ids(self): """Test that a game doesn't have item id overlap within its own datapackage""" for gamename, world_type in AutoWorldRegister.world_types.items(): with self.subTest(game=gamename): - self.assertEqual(len(world_type.item_id_to_name), len(world_type.item_name_to_id)) + overlap = "" + if len(world_type.item_id_to_name) != len(world_type.item_name_to_id): + overlap = \ + set(world_type.item_id_to_name.values()) \ + .symmetric_difference(set(world_type.item_name_to_id.keys())) or \ + set(world_type.item_name_to_id.keys()) \ + .symmetric_difference(set(world_type.item_id_to_name.values())) + self.assertEqual(len(world_type.item_id_to_name), len(world_type.item_name_to_id), + f"Game: {gamename}, Overlap: {overlap}") def test_duplicate_location_ids(self): """Test that a game doesn't have location id overlap within its own datapackage""" for gamename, world_type in AutoWorldRegister.world_types.items(): with self.subTest(game=gamename): - self.assertEqual(len(world_type.location_id_to_name), len(world_type.location_name_to_id)) + overlap = "" + if len(world_type.item_id_to_name) != len(world_type.item_name_to_id): + overlap = \ + set(world_type.location_id_to_name.values()) \ + .symmetric_difference(set(world_type.location_name_to_id.keys())) or \ + set(world_type.location_name_to_id.keys()) \ + .symmetric_difference(set(world_type.location_id_to_name.values())) + + self.assertEqual(len(world_type.location_id_to_name), len(world_type.location_name_to_id), + f"Game: {gamename}, Overlap: {overlap}") From 947a985a673ccdea694052fd61f82d7d29fac00d Mon Sep 17 00:00:00 2001 From: Jarno Westhof Date: Tue, 14 Nov 2023 23:31:19 +0100 Subject: [PATCH 2/3] Some improvements --- test/general/test_ids.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/test/general/test_ids.py b/test/general/test_ids.py index 1551b03595e4..bc74e2e14696 100644 --- a/test/general/test_ids.py +++ b/test/general/test_ids.py @@ -59,27 +59,24 @@ def test_duplicate_item_ids(self): """Test that a game doesn't have item id overlap within its own datapackage""" for gamename, world_type in AutoWorldRegister.world_types.items(): with self.subTest(game=gamename): - overlap = "" + overlap = False if len(world_type.item_id_to_name) != len(world_type.item_name_to_id): overlap = \ set(world_type.item_id_to_name.values()) \ .symmetric_difference(set(world_type.item_name_to_id.keys())) or \ - set(world_type.item_name_to_id.keys()) \ - .symmetric_difference(set(world_type.item_id_to_name.values())) - self.assertEqual(len(world_type.item_id_to_name), len(world_type.item_name_to_id), - f"Game: {gamename}, Overlap: {overlap}") + set(world_type.item_id_to_name.keys()) \ + .symmetric_difference(set(world_type.item_name_to_id.values())) + self.assertFalse(overlap) def test_duplicate_location_ids(self): """Test that a game doesn't have location id overlap within its own datapackage""" for gamename, world_type in AutoWorldRegister.world_types.items(): with self.subTest(game=gamename): - overlap = "" + overlap = False if len(world_type.item_id_to_name) != len(world_type.item_name_to_id): overlap = \ set(world_type.location_id_to_name.values()) \ .symmetric_difference(set(world_type.location_name_to_id.keys())) or \ - set(world_type.location_name_to_id.keys()) \ - .symmetric_difference(set(world_type.location_id_to_name.values())) - - self.assertEqual(len(world_type.location_id_to_name), len(world_type.location_name_to_id), - f"Game: {gamename}, Overlap: {overlap}") + set(world_type.location_id_to_name.keys()) \ + .symmetric_difference(set(world_type.location_name_to_id.values())) + self.assertFalse(overlap) From 783689ffe5558e0bc7a48891ae1fd5ed134cacb9 Mon Sep 17 00:00:00 2001 From: Jarno Westhof Date: Tue, 14 Nov 2023 23:37:54 +0100 Subject: [PATCH 3/3] Make it clear some test dont run specifically for a game but for all games in total --- test/general/test_ids.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/general/test_ids.py b/test/general/test_ids.py index bc74e2e14696..f6d8f9ba63a2 100644 --- a/test/general/test_ids.py +++ b/test/general/test_ids.py @@ -6,7 +6,7 @@ class TestIDs(unittest.TestCase): def test_unique_items(self): """Tests that every game has a unique ID per item in the datapackage""" known_item_ids = set() - for gamename, world_type in AutoWorldRegister.world_types.items(): + for world_type in AutoWorldRegister.world_types.values(): current = len(known_item_ids) known_item_ids |= set(world_type.item_id_to_name) self.assertEqual(len(known_item_ids) - len(world_type.item_id_to_name), current) @@ -14,7 +14,7 @@ def test_unique_items(self): def test_unique_locations(self): """Tests that every game has a unique ID per location in the datapackage""" known_location_ids = set() - for gamename, world_type in AutoWorldRegister.world_types.items(): + for world_type in AutoWorldRegister.world_types.values(): current = len(known_location_ids) known_location_ids |= set(world_type.location_id_to_name) self.assertEqual(len(known_location_ids) - len(world_type.location_id_to_name), current)