Skip to content

Commit

Permalink
merges nonlocalized string datatype tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongundel authored and jacobtylerwalls committed Nov 8, 2024
1 parent 0a34aff commit dbd103a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 28 deletions.
28 changes: 0 additions & 28 deletions tests/utils/datatypes/datatype_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit dbd103a

Please sign in to comment.