mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
Run black on IfcTester
This commit is contained in:
@@ -352,7 +352,7 @@ class Classification(Facet):
|
|||||||
|
|
||||||
def __call__(self, inst, logger=None):
|
def __call__(self, inst, logger=None):
|
||||||
if self.cardinality == "optional":
|
if self.cardinality == "optional":
|
||||||
return ClassificationResult(True) # Is this really the correct behaviour?
|
return ClassificationResult(True) # Is this really the correct behaviour?
|
||||||
|
|
||||||
leaf_references = ifcopenshell.util.classification.get_references(inst)
|
leaf_references = ifcopenshell.util.classification.get_references(inst)
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,18 @@ import datetime
|
|||||||
from xmlschema import XMLSchema
|
from xmlschema import XMLSchema
|
||||||
from xmlschema import etree_tostring
|
from xmlschema import etree_tostring
|
||||||
from xml.etree import ElementTree as ET
|
from xml.etree import ElementTree as ET
|
||||||
from .facet import Facet, Entity, Attribute, Classification, Property, PartOf, Material, Restriction, get_pset, get_psets
|
from .facet import (
|
||||||
|
Facet,
|
||||||
|
Entity,
|
||||||
|
Attribute,
|
||||||
|
Classification,
|
||||||
|
Property,
|
||||||
|
PartOf,
|
||||||
|
Material,
|
||||||
|
Restriction,
|
||||||
|
get_pset,
|
||||||
|
get_psets,
|
||||||
|
)
|
||||||
from typing import List, Set
|
from typing import List, Set
|
||||||
|
|
||||||
cwd = os.path.dirname(os.path.realpath(__file__))
|
cwd = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|||||||
@@ -226,9 +226,7 @@ class TestAttribute:
|
|||||||
assert attribute.asdict("applicability") == {"name": {"simpleValue": "name"}}
|
assert attribute.asdict("applicability") == {"name": {"simpleValue": "name"}}
|
||||||
attribute = Attribute(name="name", value="value")
|
attribute = Attribute(name="name", value="value")
|
||||||
assert attribute.asdict("applicability") == {"name": {"simpleValue": "name"}, "value": {"simpleValue": "value"}}
|
assert attribute.asdict("applicability") == {"name": {"simpleValue": "name"}, "value": {"simpleValue": "value"}}
|
||||||
attribute = Attribute(
|
attribute = Attribute(name="name", value="value", cardinality="required", instructions="instructions")
|
||||||
name="name", value="value", cardinality="required", instructions="instructions"
|
|
||||||
)
|
|
||||||
assert attribute.asdict("requirement") == {
|
assert attribute.asdict("requirement") == {
|
||||||
"name": {"simpleValue": "name"},
|
"name": {"simpleValue": "name"},
|
||||||
"value": {"simpleValue": "value"},
|
"value": {"simpleValue": "value"},
|
||||||
@@ -668,9 +666,13 @@ class TestAttribute:
|
|||||||
class TestClassification:
|
class TestClassification:
|
||||||
def test_creating_a_classification_facet(self):
|
def test_creating_a_classification_facet(self):
|
||||||
facet = Classification(system="system")
|
facet = Classification(system="system")
|
||||||
assert facet.asdict("requirement") == {"system": {"simpleValue": "system"}, "@cardinality": "required" }
|
assert facet.asdict("requirement") == {"system": {"simpleValue": "system"}, "@cardinality": "required"}
|
||||||
facet = Classification(value="value", system="system")
|
facet = Classification(value="value", system="system")
|
||||||
assert facet.asdict("requirement") == {"value": {"simpleValue": "value"}, "system": {"simpleValue": "system"}, "@cardinality": "required" }
|
assert facet.asdict("requirement") == {
|
||||||
|
"value": {"simpleValue": "value"},
|
||||||
|
"system": {"simpleValue": "system"},
|
||||||
|
"@cardinality": "required",
|
||||||
|
}
|
||||||
facet = Classification(
|
facet = Classification(
|
||||||
value="value",
|
value="value",
|
||||||
system="system",
|
system="system",
|
||||||
@@ -833,7 +835,7 @@ class TestProperty:
|
|||||||
assert facet.asdict("requirement") == {
|
assert facet.asdict("requirement") == {
|
||||||
"propertySet": {"simpleValue": "Property_Set"},
|
"propertySet": {"simpleValue": "Property_Set"},
|
||||||
"baseName": {"simpleValue": "PropertyName"},
|
"baseName": {"simpleValue": "PropertyName"},
|
||||||
"@cardinality": "required"
|
"@cardinality": "required",
|
||||||
}
|
}
|
||||||
facet = Property(
|
facet = Property(
|
||||||
propertySet="propertySet",
|
propertySet="propertySet",
|
||||||
@@ -1242,9 +1244,7 @@ class TestMaterial:
|
|||||||
def test_creating_a_material_facet(self):
|
def test_creating_a_material_facet(self):
|
||||||
facet = Material()
|
facet = Material()
|
||||||
assert facet.asdict("requirement") == {"@cardinality": "required"}
|
assert facet.asdict("requirement") == {"@cardinality": "required"}
|
||||||
facet = Material(
|
facet = Material(value="value", uri="https://test.com", cardinality="required", instructions="instructions")
|
||||||
value="value", uri="https://test.com", cardinality="required", instructions="instructions"
|
|
||||||
)
|
|
||||||
assert facet.asdict("requirement") == {
|
assert facet.asdict("requirement") == {
|
||||||
"value": {"simpleValue": "value"},
|
"value": {"simpleValue": "value"},
|
||||||
"@uri": "https://test.com",
|
"@uri": "https://test.com",
|
||||||
@@ -1398,7 +1398,10 @@ class TestMaterial:
|
|||||||
class TestPartOf:
|
class TestPartOf:
|
||||||
def test_creating_a_partof_facet(self):
|
def test_creating_a_partof_facet(self):
|
||||||
facet = PartOf()
|
facet = PartOf()
|
||||||
assert facet.asdict("requirement") == {"entity": {"name": {"simpleValue": "IFCWALL"}}, "@cardinality": "required" }
|
assert facet.asdict("requirement") == {
|
||||||
|
"entity": {"name": {"simpleValue": "IFCWALL"}},
|
||||||
|
"@cardinality": "required",
|
||||||
|
}
|
||||||
facet = PartOf(
|
facet = PartOf(
|
||||||
name="IFCGROUP",
|
name="IFCGROUP",
|
||||||
predefinedType="predefinedType",
|
predefinedType="predefinedType",
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ class TestIds:
|
|||||||
specs,
|
specs,
|
||||||
model,
|
model,
|
||||||
True,
|
True,
|
||||||
[wall, waldo]
|
[wall, waldo],
|
||||||
)
|
)
|
||||||
|
|
||||||
spec.ifcVersion = []
|
spec.ifcVersion = []
|
||||||
@@ -158,10 +158,23 @@ class TestIds:
|
|||||||
run("Prohibited specifications fail if at least one entity passes all requirements 1/3", specs, model, True)
|
run("Prohibited specifications fail if at least one entity passes all requirements 1/3", specs, model, True)
|
||||||
model = ifcopenshell.file()
|
model = ifcopenshell.file()
|
||||||
wall = model.createIfcWall(Name="Wally")
|
wall = model.createIfcWall(Name="Wally")
|
||||||
run("Prohibited specifications fail if at least one entity passes all requirements 2/3", specs, model, False, [wall], [wall])
|
run(
|
||||||
|
"Prohibited specifications fail if at least one entity passes all requirements 2/3",
|
||||||
|
specs,
|
||||||
|
model,
|
||||||
|
False,
|
||||||
|
[wall],
|
||||||
|
[wall],
|
||||||
|
)
|
||||||
model = ifcopenshell.file()
|
model = ifcopenshell.file()
|
||||||
wall = model.createIfcWall(Name="Waldo")
|
wall = model.createIfcWall(Name="Waldo")
|
||||||
run("Prohibited specifications fail if at least one entity passes all requirements 3/3", specs, model, False, [wall])
|
run(
|
||||||
|
"Prohibited specifications fail if at least one entity passes all requirements 3/3",
|
||||||
|
specs,
|
||||||
|
model,
|
||||||
|
False,
|
||||||
|
[wall],
|
||||||
|
)
|
||||||
|
|
||||||
spec.minOccurs = 0
|
spec.minOccurs = 0
|
||||||
spec.maxOccurs = "unbounded"
|
spec.maxOccurs = "unbounded"
|
||||||
@@ -258,43 +271,78 @@ class TestSpecification:
|
|||||||
"applicability": {},
|
"applicability": {},
|
||||||
"requirements": {},
|
"requirements": {},
|
||||||
}
|
}
|
||||||
|
|
||||||
def test_specification_has_no_requirements(self):
|
def test_specification_has_no_requirements(self):
|
||||||
model = ifcopenshell.file()
|
model = ifcopenshell.file()
|
||||||
wall = model.createIfcWall()
|
wall = model.createIfcWall()
|
||||||
waldo = model.createIfcWall(Name="Waldo")
|
waldo = model.createIfcWall(Name="Waldo")
|
||||||
|
|
||||||
test_ids = ids.Ids(title="Title")
|
test_ids = ids.Ids(title="Title")
|
||||||
spec = ids.Specification(name="Name")
|
spec = ids.Specification(name="Name")
|
||||||
spec.applicability.append(ids.Entity(name="IFCWALL"))
|
spec.applicability.append(ids.Entity(name="IFCWALL"))
|
||||||
test_ids.specifications.append(spec)
|
test_ids.specifications.append(spec)
|
||||||
spec.minOccurs = 1
|
spec.minOccurs = 1
|
||||||
run("A specification that is required and has at least one applicable entity but no requirements shall pass", test_ids, model, True, [wall, waldo], None)
|
run(
|
||||||
|
"A specification that is required and has at least one applicable entity but no requirements shall pass",
|
||||||
|
test_ids,
|
||||||
|
model,
|
||||||
|
True,
|
||||||
|
[wall, waldo],
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
|
||||||
test_ids = ids.Ids(title="Title")
|
test_ids = ids.Ids(title="Title")
|
||||||
spec = ids.Specification(name="Name")
|
spec = ids.Specification(name="Name")
|
||||||
test_ids.specifications.append(spec)
|
test_ids.specifications.append(spec)
|
||||||
spec.minOccurs = 1
|
spec.minOccurs = 1
|
||||||
run("A specification that is required but has no applicable entities or requirements shall fail", test_ids, model, False, None, None)
|
run(
|
||||||
|
"A specification that is required but has no applicable entities or requirements shall fail",
|
||||||
|
test_ids,
|
||||||
|
model,
|
||||||
|
False,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
|
||||||
test_ids = ids.Ids(title="Title")
|
test_ids = ids.Ids(title="Title")
|
||||||
spec = ids.Specification(name="Name")
|
spec = ids.Specification(name="Name")
|
||||||
spec.applicability.append(ids.Entity(name="IFCWALL"))
|
spec.applicability.append(ids.Entity(name="IFCWALL"))
|
||||||
test_ids.specifications.append(spec)
|
test_ids.specifications.append(spec)
|
||||||
spec.minOccurs = 0
|
spec.minOccurs = 0
|
||||||
run("A specification that is optional and has at least one applicable entity but no requirements shall pass", test_ids, model, True, [wall, waldo], None)
|
run(
|
||||||
|
"A specification that is optional and has at least one applicable entity but no requirements shall pass",
|
||||||
|
test_ids,
|
||||||
|
model,
|
||||||
|
True,
|
||||||
|
[wall, waldo],
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
|
||||||
test_ids = ids.Ids(title="Title")
|
test_ids = ids.Ids(title="Title")
|
||||||
spec = ids.Specification(name="Name")
|
spec = ids.Specification(name="Name")
|
||||||
spec.applicability.append(ids.Entity(name="IFCWALL"))
|
spec.applicability.append(ids.Entity(name="IFCWALL"))
|
||||||
test_ids.specifications.append(spec)
|
test_ids.specifications.append(spec)
|
||||||
spec.minOccurs = 0
|
spec.minOccurs = 0
|
||||||
spec.maxOccurs = 0
|
spec.maxOccurs = 0
|
||||||
run("A specification that is prohibited and has at least one applicable entity but no requirements shall fail", test_ids, model, False, [wall, waldo], None)
|
run(
|
||||||
|
"A specification that is prohibited and has at least one applicable entity but no requirements shall fail",
|
||||||
|
test_ids,
|
||||||
|
model,
|
||||||
|
False,
|
||||||
|
[wall, waldo],
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
|
||||||
test_ids = ids.Ids(title="Title")
|
test_ids = ids.Ids(title="Title")
|
||||||
spec = ids.Specification(name="Name")
|
spec = ids.Specification(name="Name")
|
||||||
test_ids.specifications.append(spec)
|
test_ids.specifications.append(spec)
|
||||||
spec.minOccurs = 0
|
spec.minOccurs = 0
|
||||||
spec.maxOccurs = 0
|
spec.maxOccurs = 0
|
||||||
run("A specification that is prohibited but has no applicable entities or requirements shall pass", test_ids, model, True, None, None)
|
run(
|
||||||
|
"A specification that is prohibited but has no applicable entities or requirements shall pass",
|
||||||
|
test_ids,
|
||||||
|
model,
|
||||||
|
True,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user