def test_tagset_inference(): g = Graph(load_brick=False) g.load_extension("shacl_tag_inference") data = pkgutil.get_data(__name__, "data/tags.ttl").decode() g.load_file(source=io.StringIO(data)) g.expand(profile="shacl") afs1 = g.query("SELECT ?x WHERE { ?x rdf:type brick:Air_Flow_Sensor }") assert len(afs1) == 1 afsp1 = g.query("SELECT ?x WHERE { ?x rdf:type brick:Air_Flow_Setpoint }") assert len(afsp1) == 1 mafs1 = g.query( "SELECT ?x WHERE { ?x rdf:type brick:Max_Air_Flow_Setpoint_Limit }") assert len(mafs1) == 1
def test_brick_inference(): g = Graph(load_brick=True) g.load_extension("shacl_tag_inference") data = pkgutil.get_data(__name__, "data/brick_inference_test.ttl").decode() g.load_file(source=io.StringIO(data)) g.expand(profile="brick") r = g.query("SELECT ?x WHERE { ?x rdf:type brick:Air_Temperature_Sensor }") # assert len(r) == 5 urls = set([str(row[0]) for row in r]) real_sensors = set([ "http://example.com/mybuilding#sensor1", "http://example.com/mybuilding#sensor2", "http://example.com/mybuilding#sensor3", "http://example.com/mybuilding#sensor4", "http://example.com/mybuilding#sensor5", ]) assert urls == real_sensors