mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58: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):
|
||||
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)
|
||||
|
||||
|
||||
@@ -21,7 +21,18 @@ import datetime
|
||||
from xmlschema import XMLSchema
|
||||
from xmlschema import etree_tostring
|
||||
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
|
||||
|
||||
cwd = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
@@ -226,9 +226,7 @@ class TestAttribute:
|
||||
assert attribute.asdict("applicability") == {"name": {"simpleValue": "name"}}
|
||||
attribute = Attribute(name="name", value="value")
|
||||
assert attribute.asdict("applicability") == {"name": {"simpleValue": "name"}, "value": {"simpleValue": "value"}}
|
||||
attribute = Attribute(
|
||||
name="name", value="value", cardinality="required", instructions="instructions"
|
||||
)
|
||||
attribute = Attribute(name="name", value="value", cardinality="required", instructions="instructions")
|
||||
assert attribute.asdict("requirement") == {
|
||||
"name": {"simpleValue": "name"},
|
||||
"value": {"simpleValue": "value"},
|
||||
@@ -668,9 +666,13 @@ class TestAttribute:
|
||||
class TestClassification:
|
||||
def test_creating_a_classification_facet(self):
|
||||
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")
|
||||
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(
|
||||
value="value",
|
||||
system="system",
|
||||
@@ -833,7 +835,7 @@ class TestProperty:
|
||||
assert facet.asdict("requirement") == {
|
||||
"propertySet": {"simpleValue": "Property_Set"},
|
||||
"baseName": {"simpleValue": "PropertyName"},
|
||||
"@cardinality": "required"
|
||||
"@cardinality": "required",
|
||||
}
|
||||
facet = Property(
|
||||
propertySet="propertySet",
|
||||
@@ -1242,9 +1244,7 @@ class TestMaterial:
|
||||
def test_creating_a_material_facet(self):
|
||||
facet = Material()
|
||||
assert facet.asdict("requirement") == {"@cardinality": "required"}
|
||||
facet = Material(
|
||||
value="value", uri="https://test.com", cardinality="required", instructions="instructions"
|
||||
)
|
||||
facet = Material(value="value", uri="https://test.com", cardinality="required", instructions="instructions")
|
||||
assert facet.asdict("requirement") == {
|
||||
"value": {"simpleValue": "value"},
|
||||
"@uri": "https://test.com",
|
||||
@@ -1398,7 +1398,10 @@ class TestMaterial:
|
||||
class TestPartOf:
|
||||
def test_creating_a_partof_facet(self):
|
||||
facet = PartOf()
|
||||
assert facet.asdict("requirement") == {"entity": {"name": {"simpleValue": "IFCWALL"}}, "@cardinality": "required" }
|
||||
assert facet.asdict("requirement") == {
|
||||
"entity": {"name": {"simpleValue": "IFCWALL"}},
|
||||
"@cardinality": "required",
|
||||
}
|
||||
facet = PartOf(
|
||||
name="IFCGROUP",
|
||||
predefinedType="predefinedType",
|
||||
|
||||
@@ -134,7 +134,7 @@ class TestIds:
|
||||
specs,
|
||||
model,
|
||||
True,
|
||||
[wall, waldo]
|
||||
[wall, waldo],
|
||||
)
|
||||
|
||||
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)
|
||||
model = ifcopenshell.file()
|
||||
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()
|
||||
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.maxOccurs = "unbounded"
|
||||
@@ -258,43 +271,78 @@ class TestSpecification:
|
||||
"applicability": {},
|
||||
"requirements": {},
|
||||
}
|
||||
|
||||
|
||||
def test_specification_has_no_requirements(self):
|
||||
model = ifcopenshell.file()
|
||||
wall = model.createIfcWall()
|
||||
waldo = model.createIfcWall(Name="Waldo")
|
||||
|
||||
|
||||
test_ids = ids.Ids(title="Title")
|
||||
spec = ids.Specification(name="Name")
|
||||
spec.applicability.append(ids.Entity(name="IFCWALL"))
|
||||
test_ids.specifications.append(spec)
|
||||
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")
|
||||
spec = ids.Specification(name="Name")
|
||||
test_ids.specifications.append(spec)
|
||||
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")
|
||||
spec = ids.Specification(name="Name")
|
||||
spec.applicability.append(ids.Entity(name="IFCWALL"))
|
||||
test_ids.specifications.append(spec)
|
||||
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")
|
||||
spec = ids.Specification(name="Name")
|
||||
spec.applicability.append(ids.Entity(name="IFCWALL"))
|
||||
test_ids.specifications.append(spec)
|
||||
spec.minOccurs = 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")
|
||||
spec = ids.Specification(name="Name")
|
||||
test_ids.specifications.append(spec)
|
||||
spec.minOccurs = 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