diff options
Diffstat (limited to 'test/schema/test_serialize.py')
-rw-r--r-- | test/schema/test_serialize.py | 126 |
1 files changed, 63 insertions, 63 deletions
diff --git a/test/schema/test_serialize.py b/test/schema/test_serialize.py index 7392cc0..b9d8599 100644 --- a/test/schema/test_serialize.py +++ b/test/schema/test_serialize.py @@ -66,7 +66,7 @@ class TestFromString(unittest.TestCase): ''') # additional nodes can be defined - n_unused = types.ROOT_NODE.get_child(ns.bsfs.unused) + n_unused = types.ROOT_NODE.child(ns.bsfs.unused) self.assertEqual(Schema({}, {n_unused}), from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> @@ -77,10 +77,10 @@ class TestFromString(unittest.TestCase): ''')) # a node can have multiple children - n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity) - n_tag = types.ROOT_NODE.get_child(ns.bsfs.Tag) - n_doc = n_ent.get_child(ns.bsfs.Document) - n_image = n_ent.get_child(ns.bsfs.Image) + n_ent = types.ROOT_NODE.child(ns.bsfs.Entity) + n_tag = types.ROOT_NODE.child(ns.bsfs.Tag) + n_doc = n_ent.child(ns.bsfs.Document) + n_image = n_ent.child(ns.bsfs.Image) self.assertEqual(Schema({}, {n_ent, n_tag, n_doc, n_image}), from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> @@ -97,9 +97,9 @@ class TestFromString(unittest.TestCase): ''')) # additional nodes can be defined and used - n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity) - l_string = types.ROOT_LITERAL.get_child(ns.xsd.string) - p_filename = types.ROOT_PREDICATE.get_child(ns.bse.filename, + n_ent = types.ROOT_NODE.child(ns.bsfs.Entity) + l_string = types.ROOT_LITERAL.child(ns.xsd.string) + p_filename = types.ROOT_PREDICATE.child(ns.bse.filename, n_ent, l_string, False) self.assertEqual(Schema({p_filename}), from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -168,7 +168,7 @@ class TestFromString(unittest.TestCase): ''') # additional literals can be defined - l_unused = types.ROOT_LITERAL.get_child(ns.xsd.unused) + l_unused = types.ROOT_LITERAL.child(ns.xsd.unused) self.assertEqual(Schema({}, {}, {l_unused}), from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> @@ -179,10 +179,10 @@ class TestFromString(unittest.TestCase): ''')) # a literal can have multiple children - l_string = types.ROOT_LITERAL.get_child(ns.xsd.string) - l_integer = types.ROOT_LITERAL.get_child(ns.xsd.integer) - l_unsigned = l_integer.get_child(ns.xsd.unsigned) - l_signed = l_integer.get_child(ns.xsd.signed) + l_string = types.ROOT_LITERAL.child(ns.xsd.string) + l_integer = types.ROOT_LITERAL.child(ns.xsd.integer) + l_unsigned = l_integer.child(ns.xsd.unsigned) + l_signed = l_integer.child(ns.xsd.signed) self.assertEqual(Schema({}, {}, {l_string, l_integer, l_unsigned, l_signed}), from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> @@ -199,9 +199,9 @@ class TestFromString(unittest.TestCase): ''')) # additional literals can be defined and used - n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity) - l_string = types.ROOT_LITERAL.get_child(ns.xsd.string) - p_filename = types.ROOT_PREDICATE.get_child(ns.bse.filename, + n_ent = types.ROOT_NODE.child(ns.bsfs.Entity) + l_string = types.ROOT_LITERAL.child(ns.xsd.string) + p_filename = types.ROOT_PREDICATE.child(ns.bse.filename, n_ent, l_string, False) self.assertEqual(Schema({p_filename}), from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -317,9 +317,9 @@ class TestFromString(unittest.TestCase): ''') # additional predicates can be defined - n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity) - l_string = types.ROOT_LITERAL.get_child(ns.xsd.string) - p_comment = types.ROOT_PREDICATE.get_child(ns.bse.comment, domain=n_ent, range=l_string, unique=False) + n_ent = types.ROOT_NODE.child(ns.bsfs.Entity) + l_string = types.ROOT_LITERAL.child(ns.xsd.string) + p_comment = types.ROOT_PREDICATE.child(ns.bse.comment, domain=n_ent, range=l_string, unique=False) self.assertEqual(Schema({p_comment}), from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> @@ -336,10 +336,10 @@ class TestFromString(unittest.TestCase): ''')) # predicates inherit properties from parents - n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity) - l_string = types.ROOT_LITERAL.get_child(ns.xsd.string) - p_annotation = types.ROOT_PREDICATE.get_child(ns.bsfs.Annotation, domain=n_ent, range=l_string) - p_comment = p_annotation.get_child(ns.bse.comment, unique=True) + n_ent = types.ROOT_NODE.child(ns.bsfs.Entity) + l_string = types.ROOT_LITERAL.child(ns.xsd.string) + p_annotation = types.ROOT_PREDICATE.child(ns.bsfs.Annotation, domain=n_ent, range=l_string) + p_comment = p_annotation.child(ns.bse.comment, unique=True) self.assertEqual(Schema({p_comment}), from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> @@ -358,10 +358,10 @@ class TestFromString(unittest.TestCase): ''')) # we can define partial predicates (w/o specifying a usable range) - n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity) - l_string = types.ROOT_LITERAL.get_child(ns.xsd.string) - p_annotation = types.ROOT_PREDICATE.get_child(ns.bsfs.Annotation, domain=n_ent) - p_comment = p_annotation.get_child(ns.bse.comment, range=l_string, unique=False) + n_ent = types.ROOT_NODE.child(ns.bsfs.Entity) + l_string = types.ROOT_LITERAL.child(ns.xsd.string) + p_annotation = types.ROOT_PREDICATE.child(ns.bsfs.Annotation, domain=n_ent) + p_comment = p_annotation.child(ns.bse.comment, range=l_string, unique=False) self.assertEqual(Schema({p_comment}), from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> @@ -381,8 +381,8 @@ class TestFromString(unittest.TestCase): # predicate definition can be split across multiple statements. # statements can be repeated - n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity) - p_foo = types.ROOT_PREDICATE.get_child(ns.bse.foo, domain=n_ent, range=types.ROOT_NODE, unique=True) + n_ent = types.ROOT_NODE.child(ns.bsfs.Entity) + p_foo = types.ROOT_PREDICATE.child(ns.bse.foo, domain=n_ent, range=types.ROOT_NODE, unique=True) self.assertEqual(Schema({p_foo}), from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> @@ -400,11 +400,11 @@ class TestFromString(unittest.TestCase): ''')) # domain must be a subtype of parent's domain - n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity) - n_image = n_ent.get_child(ns.bsfs.Image) - p_foo = types.ROOT_PREDICATE.get_child(ns.bse.foo, domain=types.ROOT_NODE) - p_bar = p_foo.get_child(ns.bse.bar, domain=n_ent) - p_foobar = p_bar.get_child(ns.bse.foobar, domain=n_image) + n_ent = types.ROOT_NODE.child(ns.bsfs.Entity) + n_image = n_ent.child(ns.bsfs.Image) + p_foo = types.ROOT_PREDICATE.child(ns.bse.foo, domain=types.ROOT_NODE) + p_bar = p_foo.child(ns.bse.bar, domain=n_ent) + p_foobar = p_bar.child(ns.bse.foobar, domain=n_image) self.assertEqual(Schema({p_foobar}), from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> @@ -439,11 +439,11 @@ class TestFromString(unittest.TestCase): ''') # range must be a subtype of parent's range - n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity) - n_image = n_ent.get_child(ns.bsfs.Image) - p_foo = types.ROOT_PREDICATE.get_child(ns.bse.foo, range=types.ROOT_NODE) - p_bar = p_foo.get_child(ns.bse.bar, range=n_ent) - p_foobar = p_bar.get_child(ns.bse.foobar, range=n_image) + n_ent = types.ROOT_NODE.child(ns.bsfs.Entity) + n_image = n_ent.child(ns.bsfs.Image) + p_foo = types.ROOT_PREDICATE.child(ns.bse.foo, range=types.ROOT_NODE) + p_bar = p_foo.child(ns.bse.bar, range=n_ent) + p_foobar = p_bar.child(ns.bse.foobar, range=n_image) self.assertEqual(Schema({p_foobar}), from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> @@ -658,9 +658,9 @@ class TestFromString(unittest.TestCase): ''') # additional predicates can be defined - n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity) - l_array = types.ROOT_LITERAL.get_child(ns.bsfs.array) - p_comment = types.ROOT_FEATURE.get_child(ns.bse.colors, domain=n_ent, range=l_array, unique=False) + n_ent = types.ROOT_NODE.child(ns.bsfs.Entity) + l_array = types.ROOT_LITERAL.child(ns.bsfs.array) + p_comment = types.ROOT_FEATURE.child(ns.bse.colors, domain=n_ent, range=l_array, unique=False) self.assertEqual(Schema({p_comment}), from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> @@ -678,12 +678,12 @@ class TestFromString(unittest.TestCase): ''')) # features inherit properties from parents - n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity) - l_array = types.ROOT_LITERAL.get_child(ns.bsfs.array) - l_string = types.ROOT_LITERAL.get_child(ns.xsd.string) - p_annotation = types.ROOT_FEATURE.get_child(ns.bsfs.Annotation, domain=n_ent, range=l_array, + n_ent = types.ROOT_NODE.child(ns.bsfs.Entity) + l_array = types.ROOT_LITERAL.child(ns.bsfs.array) + l_string = types.ROOT_LITERAL.child(ns.xsd.string) + p_annotation = types.ROOT_FEATURE.child(ns.bsfs.Annotation, domain=n_ent, range=l_array, dimension=1234, dtype=ns.xsd.string) - p_comment = p_annotation.get_child(ns.bse.colors, unique=True) + p_comment = p_annotation.child(ns.bse.colors, unique=True) self.assertEqual(Schema({p_comment}), from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> @@ -706,8 +706,8 @@ class TestFromString(unittest.TestCase): # feature definition can be split across multiple statements. # statements can be repeated - n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity) - p_foo = types.ROOT_FEATURE.get_child(ns.bse.foo, domain=n_ent, unique=True, + n_ent = types.ROOT_NODE.child(ns.bsfs.Entity) + p_foo = types.ROOT_FEATURE.child(ns.bse.foo, domain=n_ent, unique=True, dimension=1234, dtype=ns.bsfs.f32) self.assertEqual(Schema({p_foo}), from_string(''' prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> @@ -887,24 +887,24 @@ class TestFromString(unittest.TestCase): def test_integration(self): # nodes - n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity) - n_tag = types.ROOT_NODE.get_child(ns.bsfs.Tag) - n_image = n_ent.get_child(ns.bsfs.Image) + n_ent = types.ROOT_NODE.child(ns.bsfs.Entity) + n_tag = types.ROOT_NODE.child(ns.bsfs.Tag) + n_image = n_ent.child(ns.bsfs.Image) # literals - l_string = types.ROOT_LITERAL.get_child(ns.xsd.string) - l_array = types.ROOT_LITERAL.get_child(ns.bsfs.array) - l_integer = types.ROOT_LITERAL.get_child(ns.xsd.integer) - l_boolean = types.ROOT_LITERAL.get_child(ns.xsd.boolean) + l_string = types.ROOT_LITERAL.child(ns.xsd.string) + l_array = types.ROOT_LITERAL.child(ns.bsfs.array) + l_integer = types.ROOT_LITERAL.child(ns.xsd.integer) + l_boolean = types.ROOT_LITERAL.child(ns.xsd.boolean) # predicates - p_annotation = types.ROOT_PREDICATE.get_child(ns.bsfs.Annotation) - p_tag = types.ROOT_PREDICATE.get_child(ns.bse.tag, domain=n_ent, range=n_tag) - p_group = p_tag.get_child(ns.bse.group, domain=n_image, unique=True) - p_comment = p_annotation.get_child(ns.bse.comment, range=l_string) + p_annotation = types.ROOT_PREDICATE.child(ns.bsfs.Annotation) + p_tag = types.ROOT_PREDICATE.child(ns.bse.tag, domain=n_ent, range=n_tag) + p_group = p_tag.child(ns.bse.group, domain=n_image, unique=True) + p_comment = p_annotation.child(ns.bse.comment, range=l_string) # features - f_colors = types.ROOT_FEATURE.get_child(URI('http://bsfs.ai/schema/Feature/colors_spatial'), + f_colors = types.ROOT_FEATURE.child(URI('http://bsfs.ai/schema/Feature/colors_spatial'), domain=n_ent, range=l_array, unique=True, dtype=ns.bsfs.f16, distance=ns.bsfs.euclidean) - f_colors1234 = f_colors.get_child(URI('http://bsfs.ai/schema/Feature/colors_spatial#1234'), dimension=1024) - f_colors4321 = f_colors.get_child(URI('http://bsfs.ai/schema/Feature/colors_spatial#4321'), dimension=2048) + f_colors1234 = f_colors.child(URI('http://bsfs.ai/schema/Feature/colors_spatial#1234'), dimension=1024) + f_colors4321 = f_colors.child(URI('http://bsfs.ai/schema/Feature/colors_spatial#4321'), dimension=2048) # schema ref = Schema( {p_annotation, p_tag, p_group, p_comment, f_colors, f_colors1234, f_colors4321}, |