Exemplo n.º 1
0
 def test_run(self):
     BrickStore.graph = brickschema.Graph()
     result = subject.add_brick(
         "http://example.org/digitaltwin#",
         "https://brickschema.org/schema/Brick#Equipment")
     subject.remove_brick(result)
     assert not list(BrickStore.graph.triples((URIRef(result), None, None)))
Exemplo n.º 2
0
 def test_run(self):
     TestAddBrickifcProject().test_run()
     element = tool.Ifc.get().createIfcChiller(ifcopenshell.guid.new())
     project = URIRef(
         f"http://example.org/digitaltwin#{tool.Ifc.get().by_type('IfcProject')[0].GlobalId}"
     )
     subject.add_brickifc_reference("http://example.org/digitaltwin#foo",
                                    element, project)
     brick = URIRef("http://example.org/digitaltwin#foo")
     bnode = list(
         BrickStore.graph.triples(
             (brick,
              URIRef(
                  "https://brickschema.org/extension/ifc#hasIFCReference"),
              None)))[0][2]
     assert list(
         BrickStore.graph.triples((
             bnode,
             URIRef(
                 "https://brickschema.org/extension/ifc#hasProjectReference"
             ), project)))
     assert list(
         BrickStore.graph.triples(
             (bnode,
              URIRef("https://brickschema.org/extension/ifc#globalID"),
              Literal(element.GlobalId))))
Exemplo n.º 3
0
 def test_run(self):
     TestLoadBrickFile().test_run()
     subject.import_brick_items("Building")
     assert len(bpy.context.scene.BIMBrickProperties.bricks) == 1
     brick = bpy.context.scene.BIMBrickProperties.bricks[0]
     assert brick.name == "bldg"
     assert brick.label == "My Building"
     assert brick.uri == "https://example.org/digitaltwin#bldg"
     assert brick.total_items == 0
Exemplo n.º 4
0
 def test_run(self):
     BrickStore.graph = "graph"
     bpy.context.scene.BIMBrickProperties.active_brick_class == "brick_class"
     bpy.context.scene.BIMBrickProperties.brick_breadcrumbs.add(
     ).name = "foo"
     subject.clear_project()
     assert BrickStore.graph is None
     assert bpy.context.scene.BIMBrickProperties.active_brick_class == ""
     assert len(bpy.context.scene.BIMBrickProperties.brick_breadcrumbs) == 0
Exemplo n.º 5
0
 def test_run(self):
     BrickStore.graph = brickschema.Graph()
     subject.add_feed("http://example.org/digitaltwin#source",
                      "http://example.org/digitaltwin#destination")
     assert list(
         BrickStore.graph.triples((
             URIRef("http://example.org/digitaltwin#source"),
             URIRef("https://brickschema.org/schema/Brick#feeds"),
             URIRef("http://example.org/digitaltwin#destination"),
         )))
Exemplo n.º 6
0
    def test_run(self):
        # We stub the schema to make tests run faster
        BrickStore.schema = brickschema.Graph()
        cwd = os.path.dirname(os.path.realpath(__file__))
        schema_path = os.path.join(cwd, "..", "files", "BrickStub.ttl")
        BrickStore.schema.load_file(schema_path)

        # This is the actual test
        cwd = os.path.dirname(os.path.realpath(__file__))
        filepath = os.path.join(cwd, "..", "files", "spaces.ttl")
        subject.load_brick_file(filepath)
        assert BrickStore.graph
Exemplo n.º 7
0
 def test_run(self):
     TestLoadBrickFile().test_run()
     subject.import_brick_classes("Class")
     assert len(bpy.context.scene.BIMBrickProperties.bricks) == 2
     brick = bpy.context.scene.BIMBrickProperties.bricks[0]
     assert brick.name == "Building"
     assert brick.uri == "https://brickschema.org/schema/Brick#Building"
     assert brick.total_items == 1
     assert not brick.label
     brick = bpy.context.scene.BIMBrickProperties.bricks[1]
     assert brick.name == "Location"
     assert brick.uri == "https://brickschema.org/schema/Brick#Location"
     assert brick.total_items == 1
     assert not brick.label
Exemplo n.º 8
0
 def test_run_ifc2x3(self):
     tool.Ifc.set(ifcopenshell.file(schema="IFC2X3"))
     assert subject.export_brick_attributes(
         "http://example.org/digitaltwin#floor") == {
             "ItemReference": "http://example.org/digitaltwin#floor",
             "Name": "floor",
         }
Exemplo n.º 9
0
 def test_run(self):
     ifc = ifcopenshell.file()
     tool.Ifc.set(ifc)
     project = ifc.createIfcProject(ifcopenshell.guid.new())
     project.Name = "My Project"
     BrickStore.graph = brickschema.Graph()
     result = subject.add_brickifc_project(
         "http://example.org/digitaltwin#")
     assert result == f"http://example.org/digitaltwin#{project.GlobalId}"
     brick = URIRef(result)
     assert list(
         BrickStore.graph.triples(
             (brick, RDF.type,
              URIRef("https://brickschema.org/extension/ifc#Project"))))
     assert list(
         BrickStore.graph.triples(
             (brick, URIRef("http://www.w3.org/2000/01/rdf-schema#label"),
              Literal("My Project"))))
     assert list(
         BrickStore.graph.triples(
             (brick,
              URIRef("https://brickschema.org/extension/ifc#projectID"),
              Literal(project.GlobalId))))
     assert list(
         BrickStore.graph.triples((
             brick,
             URIRef("https://brickschema.org/extension/ifc#fileLocation"),
             Literal(bpy.context.scene.BIMProperties.ifc_file),
         )))
Exemplo n.º 10
0
    def test_run(self):
        # We stub the schema to make tests run faster
        BrickStore.schema = brickschema.Graph()
        cwd = os.path.dirname(os.path.realpath(__file__))
        schema_path = os.path.join(cwd, "..", "files", "BrickStub.ttl")
        BrickStore.schema.load_file(schema_path)

        # This is the actual test
        subject.new_brick_file()
        assert BrickStore.graph
        namespaces = [(ns[0], ns[1].toPython())
                      for ns in BrickStore.graph.namespaces()]
        assert ("digitaltwin",
                "https://example.org/digitaltwin#") in namespaces
        assert ("brick", "https://brickschema.org/schema/Brick#") in namespaces
        assert ("rdfs", "http://www.w3.org/2000/01/rdf-schema#") in namespaces
Exemplo n.º 11
0
 def test_run_ifc2x3(self):
     ifc = ifcopenshell.file(schema="IFC2X3")
     tool.Ifc.set(ifc)
     reference = ifc.createIfcLibraryReference(
         ItemReference="http://example.org/digitaltwin#floor")
     library = ifc.createIfcLibraryInformation(LibraryReference=[reference])
     assert subject.get_library_brick_reference(
         library, "http://example.org/digitaltwin#floor") == reference
Exemplo n.º 12
0
 def test_run(self):
     ifc = ifcopenshell.file()
     library = ifc.createIfcLibraryInformation()
     reference = ifc.createIfcLibraryReference(
         Identification="http://example.org/digitaltwin#floor",
         ReferencedLibrary=library)
     assert subject.get_library_brick_reference(
         library, "http://example.org/digitaltwin#floor") == reference
Exemplo n.º 13
0
 def test_run(self):
     ifc = ifcopenshell.file()
     element = ifc.createIfcChiller()
     library = ifc.createIfcLibraryReference(
         Identification="http://example.org/digitaltwin#globalid")
     ifc.createIfcRelAssociatesLibrary(RelatedObjects=[element],
                                       RelatingLibrary=library)
     assert subject.get_brick(
         element) == "http://example.org/digitaltwin#globalid"
Exemplo n.º 14
0
 def test_run(self):
     bpy.context.scene.BIMBrickProperties.brick_breadcrumbs.add(
     ).name = "foo"
     bpy.context.scene.BIMBrickProperties.brick_breadcrumbs.add(
     ).name = "bar"
     assert subject.pop_brick_breadcrumb() == "bar"
     assert len(bpy.context.scene.BIMBrickProperties.brick_breadcrumbs) == 1
     assert bpy.context.scene.BIMBrickProperties.brick_breadcrumbs[
         0].name == "foo"
Exemplo n.º 15
0
 def test_run_ifc2x3(self):
     ifc = ifcopenshell.file(schema="IFC2X3")
     tool.Ifc.set(ifc)
     element = ifc.createIfcEnergyConversionDevice()
     library = ifc.createIfcLibraryReference(
         ItemReference="http://example.org/digitaltwin#globalid")
     ifc.createIfcRelAssociatesLibrary(RelatedObjects=[element],
                                       RelatingLibrary=library)
     assert subject.get_brick(
         element) == "http://example.org/digitaltwin#globalid"
Exemplo n.º 16
0
 def test_run(self):
     subject.set_active_brick_class("brick_class")
     subject.add_brick_breadcrumb()
     assert bpy.context.scene.BIMBrickProperties.brick_breadcrumbs[
         0].name == "brick_class"
     subject.add_brick_breadcrumb()
     assert bpy.context.scene.BIMBrickProperties.brick_breadcrumbs[
         1].name == "brick_class"
Exemplo n.º 17
0
 def test_run(self):
     BrickStore.graph = brickschema.Graph()
     result = subject.add_brick(
         "https://example.org/digitaltwin#",
         "https://brickschema.org/schema/Brick#Equipment")
     assert "https://example.org/digitaltwin#" in result
     assert list(
         BrickStore.graph.triples(
             (URIRef(result), RDF.type,
              URIRef("https://brickschema.org/schema/Brick#Equipment"))))
     assert list(
         BrickStore.graph.triples(
             (URIRef(result),
              URIRef("http://www.w3.org/2000/01/rdf-schema#label"),
              Literal("Unnamed"))))
Exemplo n.º 18
0
 def test_run(self):
     ifc = ifcopenshell.file()
     element = ifc.createIfcChiller()
     element.Name = "Chiller"
     element.GlobalId = ifcopenshell.guid.new()
     BrickStore.graph = brickschema.Graph()
     result = subject.add_brick_from_element(
         element, "http://example.org/digitaltwin#",
         "https://brickschema.org/schema/Brick#Equipment")
     uri = f"http://example.org/digitaltwin#{element.GlobalId}"
     assert result == uri
     assert list(
         BrickStore.graph.triples(
             (URIRef(uri), RDF.type,
              URIRef("https://brickschema.org/schema/Brick#Equipment"))))
     assert list(
         BrickStore.graph.triples(
             (URIRef(uri),
              URIRef("http://www.w3.org/2000/01/rdf-schema#label"),
              Literal("Chiller"))))
Exemplo n.º 19
0
 def test_run(self):
     bpy.context.scene.BIMBrickProperties.bricks.add().name = "foo"
     bpy.context.scene.BIMBrickProperties.bricks.add().name = "bar"
     subject.select_browser_item("namespace#bar")
     assert bpy.context.scene.BIMBrickProperties.active_brick_index == 1
Exemplo n.º 20
0
 def test_run(self):
     subject.set_active_brick_class("brick_class")
     assert bpy.context.scene.BIMBrickProperties.active_brick_class == "brick_class"
Exemplo n.º 21
0
 def test_run(self):
     bpy.context.scene.BIMBrickProperties.bricks.add()
     subject.clear_brick_browser()
     assert len(bpy.context.scene.BIMBrickProperties.bricks) == 0
Exemplo n.º 22
0
 def test_run(self):
     TestLoadBrickFile().test_run()
     assert subject.get_brick_path_name() == "spaces.ttl"
Exemplo n.º 23
0
 def test_run(self):
     assert subject.export_brick_attributes(
         "http://example.org/digitaltwin#floor") == {
             "Identification": "http://example.org/digitaltwin#floor",
             "Name": "floor",
         }
Exemplo n.º 24
0
 def test_run(self):
     TestLoadBrickFile().test_run()
     cwd = os.path.dirname(os.path.realpath(__file__))
     assert subject.get_brick_path() == os.path.join(
         cwd, "..", "files", "spaces.ttl")
Exemplo n.º 25
0
 def test_run(self):
     assert subject.get_namespace("http://example.org/digitaltwin#globalid"
                                  ) == "http://example.org/digitaltwin#"
Exemplo n.º 26
0
 def test_run(self):
     TestAddBrickifcProject().test_run()
     assert (
         subject.get_brickifc_project() ==
         f"http://example.org/digitaltwin#{tool.Ifc.get().by_type('IfcProject')[0].GlobalId}"
     )
Exemplo n.º 27
0
 def test_run(self):
     TestLoadBrickFile().test_run()
     assert subject.get_item_class(
         "https://example.org/digitaltwin#floor") == "Floor"
Exemplo n.º 28
0
 def test_run(self):
     ifc = ifcopenshell.file()
     tool.Ifc.set(ifc)
     element = ifc.createIfcAirTerminalBox()
     ifc.createIfcWall()
     assert subject.get_convertable_brick_elements() == {element}
Exemplo n.º 29
0
 def test_run(self):
     subject.set_active_brick_class("brick_class")
     assert subject.get_active_brick_class() == "brick_class"
Exemplo n.º 30
0
 def test_run(self):
     ifc = ifcopenshell.file()
     element = ifc.createIfcAirTerminalBox()
     assert subject.get_brick_class(
         element) == "https://brickschema.org/schema/Brick#TerminalUnit"