diff --git a/examples/rec-with-brick/building.ttl b/examples/rec-with-brick/building.ttl index b2395e03..8c74d280 100644 --- a/examples/rec-with-brick/building.ttl +++ b/examples/rec-with-brick/building.ttl @@ -1,6 +1,6 @@ @prefix ex: . @prefix rec: . -@prefix brick: . +@prefix brick: . @prefix rdf: . @prefix rdfs: . @@ -58,7 +58,7 @@ ex:AirTempSensor_RVAV1 a brick:Air_Temperature_Sensor ; brick:isPointOf ex:RVAV1 . ex:AirTempSetpoint_RVAV1 a brick:Temperature_Setpoint ; - brick:hasPoint ex:RVAV1 . + brick:isPointOf ex:RVAV1 . ex:AirFlowSensor_RVAV1 a brick:Air_Flow_Sensor ; brick:isPointOf ex:RVAV1 . diff --git a/tests/conftest.py b/tests/conftest.py index 1e461571..07836d54 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,6 +2,7 @@ Generates tests automatically """ import pytest +from rdflib import Namespace import ontoenv import brickschema import glob @@ -9,6 +10,7 @@ sys.path.append("..") from bricksrc.namespaces import QUDT, RDF, RDFS, BRICK # noqa: E402 +from bricksrc.namespaces import TAG, SKOS, A, OWL # noqa: E402 def pytest_generate_tests(metafunc): @@ -41,3 +43,56 @@ def brick_with_imports(): g.bind("brick", BRICK) env.import_dependencies(g) return g + + +@pytest.fixture() +def simple_brick_model(): + BLDG = Namespace("https://brickschema.org/schema/ExampleBuilding#") + + g = brickschema.Graph() + g.load_file("Brick.ttl") + g.bind("rdf", RDF) + g.bind("owl", OWL) + g.bind("rdfs", RDFS) + g.bind("skos", SKOS) + g.bind("brick", BRICK) + g.bind("tag", TAG) + g.bind("bldg", BLDG) + + # Create instances + g.add((BLDG.Coil_1, A, BRICK.Heating_Coil)) + g.add((BLDG.AHU1, A, BRICK.Air_Handler_Unit)) + g.add((BLDG.VAV1, A, BRICK.Variable_Air_Volume_Box)) + g.add((BLDG.CH1, A, BRICK.Chiller)) + + # locations + g.add((BLDG.Zone1, A, BRICK.HVAC_Zone)) + g.add((BLDG.Room1, A, BRICK.Room)) + g.add((BLDG.Room2, A, BRICK.Room)) + + # points + g.add((BLDG.TS1, A, BRICK.Air_Temperature_Sensor)) + g.add((BLDG.TS2, A, BRICK.Air_Temperature_Sensor)) + g.add((BLDG.AFS1, A, BRICK.Air_Flow_Sensor)) + g.add((BLDG.co2s1, A, BRICK.CO2_Level_Sensor)) + + g.add((BLDG.AFSP1, A, BRICK.Air_Flow_Setpoint)) + + g.add((BLDG.MAFS1, A, BRICK.Max_Air_Flow_Setpoint_Limit)) + + # establishing some relationships + g.add((BLDG.CH1, BRICK.feeds, BLDG.AHU1)) + g.add((BLDG.AHU1, BRICK.feeds, BLDG.VAV1)) + g.add((BLDG.VAV1, BRICK.hasPoint, BLDG.TS2)) + g.add((BLDG.VAV1, BRICK.hasPoint, BLDG.AFS1)) + g.add((BLDG.VAV1, BRICK.hasPoint, BLDG.AFSP1)) + + g.add((BLDG.VAV1, BRICK.feeds, BLDG.Zone1)) + g.add((BLDG.Zone1, BRICK.hasPart, BLDG.Room1)) + g.add((BLDG.Zone1, BRICK.hasPart, BLDG.Room2)) + + g.add((BLDG.TS1, BRICK.hasLocation, BLDG.Room1)) + + # lets us use both relationships + g.expand(profile="shacl") + return g diff --git a/tests/test_no_inference.py b/tests/test_no_inference.py index 3ccdc667..bc044427 100644 --- a/tests/test_no_inference.py +++ b/tests/test_no_inference.py @@ -1,65 +1,10 @@ # Set of tests to demonstrate use of Brick *without* the use of a reasoner -import brickschema -from rdflib import RDF, RDFS, OWL, Namespace from .util import make_readable -import sys -sys.path.append("..") -from bricksrc.namespaces import BRICK, TAG, SKOS, A # noqa: E402 -BLDG = Namespace("https://brickschema.org/schema/ExampleBuilding#") - -g = brickschema.Graph() -g.load_file("Brick.ttl") -g.bind("rdf", RDF) -g.bind("owl", OWL) -g.bind("rdfs", RDFS) -g.bind("skos", SKOS) -g.bind("brick", BRICK) -g.bind("tag", TAG) -g.bind("bldg", BLDG) - -# Create instances -g.add((BLDG.Coil_1, A, BRICK.Heating_Coil)) -g.add((BLDG.AHU1, A, BRICK.Air_Handler_Unit)) -g.add((BLDG.VAV1, A, BRICK.Variable_Air_Volume_Box)) -g.add((BLDG.CH1, A, BRICK.Chiller)) - -# locations -g.add((BLDG.Zone1, A, BRICK.HVAC_Zone)) -g.add((BLDG.Room1, A, BRICK.Room)) -g.add((BLDG.Room2, A, BRICK.Room)) - -# points -g.add((BLDG.TS1, A, BRICK.Air_Temperature_Sensor)) -g.add((BLDG.TS2, A, BRICK.Air_Temperature_Sensor)) -g.add((BLDG.AFS1, A, BRICK.Air_Flow_Sensor)) -g.add((BLDG.co2s1, A, BRICK.CO2_Level_Sensor)) - -g.add((BLDG.AFSP1, A, BRICK.Air_Flow_Setpoint)) - -g.add((BLDG.MAFS1, A, BRICK.Max_Air_Flow_Setpoint_Limit)) - -# establishing some relationships -g.add((BLDG.CH1, BRICK.feeds, BLDG.AHU1)) -g.add((BLDG.AHU1, BRICK.feeds, BLDG.VAV1)) -g.add((BLDG.VAV1, BRICK.hasPoint, BLDG.TS2)) -g.add((BLDG.VAV1, BRICK.hasPoint, BLDG.AFS1)) -g.add((BLDG.VAV1, BRICK.hasPoint, BLDG.AFSP1)) - -g.add((BLDG.VAV1, BRICK.feeds, BLDG.Zone1)) -g.add((BLDG.Zone1, BRICK.hasPart, BLDG.Room1)) -g.add((BLDG.Zone1, BRICK.hasPart, BLDG.Room2)) - -g.add((BLDG.TS1, BRICK.hasLocation, BLDG.Room1)) - -# lets us use both relationships -g.expand(profile="shacl") - - -def test_query_equipment(): +def test_query_equipment(simple_brick_model): res = make_readable( - g.query( + simple_brick_model.query( """SELECT DISTINCT ?equip WHERE { ?equip rdf:type/rdfs:subClassOf* brick:Equipment . }""" @@ -68,9 +13,9 @@ def test_query_equipment(): assert len(res) == 4 -def test_query_points(): +def test_query_points(simple_brick_model): res = make_readable( - g.query( + simple_brick_model.query( """SELECT DISTINCT ?point WHERE { ?point rdf:type/rdfs:subClassOf* brick:Point . }""" @@ -79,9 +24,9 @@ def test_query_points(): assert len(res) == 6 -def test_query_sensors(): +def test_query_sensors(simple_brick_model): res = make_readable( - g.query( + simple_brick_model.query( """SELECT DISTINCT ?sensor WHERE { ?sensor rdf:type/rdfs:subClassOf* brick:Sensor . }""" @@ -90,10 +35,10 @@ def test_query_sensors(): assert len(res) == 4 -def test_query_downstream_temperature(): +def test_query_downstream_temperature(simple_brick_model): # temp sensors downstream of AHU1 res = make_readable( - g.query( + simple_brick_model.query( """SELECT DISTINCT ?thing ?point WHERE { bldg:AHU1 (brick:feeds|brick:hasPart)* ?thing . ?thing (brick:hasPoint|brick:isLocationOf) ?point . @@ -104,10 +49,10 @@ def test_query_downstream_temperature(): assert len(res) == 2 -def test_query_room_temp_sensors_ahu1(): +def test_query_room_temp_sensors_ahu1(simple_brick_model): # temp sensors downstream of AHU1 res = make_readable( - g.query( + simple_brick_model.query( """SELECT DISTINCT ?zone ?room ?sensor WHERE { bldg:AHU1 brick:feeds+ ?zone . ?zone brick:hasPart ?room . diff --git a/tools/compare_versions/compare_versions.py b/tools/compare_versions/compare_versions.py index ff98e9cc..cb05e797 100644 --- a/tools/compare_versions/compare_versions.py +++ b/tools/compare_versions/compare_versions.py @@ -20,6 +20,8 @@ def get_root(version): short_version = get_short_version(version) if short_version == "1.3": return "https://brickschema.org/schema/Brick#Class" + if short_version == "1.4": + return "https://brickschema.org/schema/Brick#Entity" if semver.compare(version, "1.0.3") > 0: # if current version is newer than 1.0.3 return f"https://brickschema.org/schema/{short_version}/Brick#Class" return f"https://brickschema.org/schema/{short_version}/BrickFrame#TagSet"