From dbd103a7ddaebbedc5f2c87c44d43898cf7c45d7 Mon Sep 17 00:00:00 2001 From: Aaron Gundel Date: Fri, 8 Nov 2024 09:50:28 -0700 Subject: [PATCH] merges nonlocalized string datatype tests --- tests/utils/datatypes/datatype_tests.py | 28 ------------------- .../non_localized_string_tests.py | 19 +++++++++++++ 2 files changed, 19 insertions(+), 28 deletions(-) rename tests/utils/{ => datatypes}/non_localized_string_tests.py (79%) diff --git a/tests/utils/datatypes/datatype_tests.py b/tests/utils/datatypes/datatype_tests.py index cac6b44650f..a26a68572fc 100644 --- a/tests/utils/datatypes/datatype_tests.py +++ b/tests/utils/datatypes/datatype_tests.py @@ -133,34 +133,6 @@ def test_tile_clean(self): self.assertIsNotNone(tile2.data[nodeid]) -class NonLocalizedStringDataTypeTests(ArchesTestCase): - def test_string_validate(self): - string = DataTypeFactory().get_instance("non-localized-string") - some_errors = string.validate(float(1.2)) - self.assertGreater(len(some_errors), 0) - no_errors = string.validate("Hello World") - self.assertEqual(len(no_errors), 0) - - def test_string_clean(self): - string = DataTypeFactory().get_instance("non-localized-string") - nodeid1 = "72048cb3-adbc-11e6-9ccf-14109fd34195" - nodeid2 = "72048cb3-adbc-11e6-9ccf-14109fd34196" - resourceinstanceid = "40000000-0000-0000-0000-000000000000" - - json_empty_strings = { - "resourceinstance_id": resourceinstanceid, - "parenttile_id": "", - "nodegroup_id": nodeid1, - "tileid": "", - "data": {nodeid1: "''", nodeid2: ""}, - } - tile1 = Tile(json_empty_strings) - string.clean(tile1, nodeid1) - self.assertIsNone(tile1.data[nodeid1]) - string.clean(tile1, nodeid2) - self.assertIsNone(tile1.data[nodeid2]) - - class URLDataTypeTests(ArchesTestCase): def test_validate(self): url = DataTypeFactory().get_instance("url") diff --git a/tests/utils/non_localized_string_tests.py b/tests/utils/datatypes/non_localized_string_tests.py similarity index 79% rename from tests/utils/non_localized_string_tests.py rename to tests/utils/datatypes/non_localized_string_tests.py index f8af900917a..304e3693fbf 100644 --- a/tests/utils/non_localized_string_tests.py +++ b/tests/utils/datatypes/non_localized_string_tests.py @@ -51,6 +51,25 @@ def test_to_rdf(self): result = nonlocalized_string_dt.to_rdf(edge_info, edge) self.assertIsInstance(result, ConjunctiveGraph) + def test_string_clean_json(self): + string = DataTypeFactory().get_instance("non-localized-string") + nodeid1 = "72048cb3-adbc-11e6-9ccf-14109fd34195" + nodeid2 = "72048cb3-adbc-11e6-9ccf-14109fd34196" + resourceinstanceid = "40000000-0000-0000-0000-000000000000" + + json_empty_strings = { + "resourceinstance_id": resourceinstanceid, + "parenttile_id": "", + "nodegroup_id": nodeid1, + "tileid": "", + "data": {nodeid1: "''", nodeid2: ""}, + } + tile1 = Tile(json_empty_strings) + string.clean(tile1, nodeid1) + self.assertIsNone(tile1.data[nodeid1]) + string.clean(tile1, nodeid2) + self.assertIsNone(tile1.data[nodeid2]) + def mock_edge( s_id,