mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Publish MicroMVD definitions for classifications
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import json
|
||||
from behave import step
|
||||
from utils import IfcFile, assert_attribute, assert_type
|
||||
|
||||
|
||||
def get_classification(name):
|
||||
classifications = [c for c in IfcFile.get().by_type('IfcClassification') if c.Name == name]
|
||||
if len(classifications) != 1:
|
||||
assert False, f'The classification "{name}" was not found'
|
||||
return classifications[0]
|
||||
|
||||
|
||||
@step(u'The classification {name} must be used')
|
||||
def step_impl(context, name):
|
||||
get_classification(name)
|
||||
|
||||
|
||||
@step(u'The classification {name} is published by {source}')
|
||||
def step_impl(context, name, source):
|
||||
assert_attribute(get_classification(name), 'Source', source)
|
||||
|
||||
|
||||
@step(u'The classification {name} is the edition {edition} on {edition_date}')
|
||||
def step_impl(context, name, edition, edition_date):
|
||||
element = get_classification(name)
|
||||
assert_attribute(element, 'Edition', edition)
|
||||
assert_attribute(element, 'EditionDate', edition_date)
|
||||
|
||||
|
||||
@step(u'The classification {name} has the description "{description}"')
|
||||
def step_impl(context, name, description):
|
||||
assert_attribute(get_classification(name), 'Description', description)
|
||||
|
||||
|
||||
@step(u'The classification {name} is referenced by the website {location}')
|
||||
def step_impl(context, name, location):
|
||||
assert_attribute(get_classification(name), 'Location', location)
|
||||
|
||||
|
||||
@step(u'The classification {name} has a hierarchy denoted by the tokens {tokens}')
|
||||
def step_impl(context, name, tokens):
|
||||
try:
|
||||
tokens = json.loads(tokens)
|
||||
except:
|
||||
assert False, f'Tokens {tokens} are not specified as a JSON list'
|
||||
assert_attribute(get_classification(name), 'ReferenceTokens', tokens)
|
||||
|
||||
|
||||
@step(u'The element {guid} is classified as a "{identification}" with name "{reference_name}"')
|
||||
def step_impl(context, guid, identification, reference_name):
|
||||
element = IfcFile.by_guid(guid)
|
||||
if not hasattr(element, 'HasAssociations') or not element.HasAssociations:
|
||||
assert False, f'The element {element} has no associations.'
|
||||
references = [a.RelatingClassification for a in element.HasAssociations if a.is_a('IfcRelAssociatesClassification')]
|
||||
if not references:
|
||||
assert False, f'The element {element} has no associated classification references.'
|
||||
is_success = False
|
||||
for reference in references:
|
||||
try:
|
||||
assert_attribute(reference, 'Identification', identification)
|
||||
assert_attribute(reference, 'Name', reference_name)
|
||||
is_success = True
|
||||
except:
|
||||
pass
|
||||
if not is_success:
|
||||
assert False, 'No classification references met the requirement for an identification {} and name {} for the element {}. The references we found were: {}'.format(identification, reference_name, element, references)
|
||||
@@ -235,7 +235,13 @@ endif
|
||||
mkdir dist/blenderbim/libs/site/packages/features/steps/
|
||||
cd dist/blenderbim/libs/site/packages/features/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcbimtester/features/environment.py
|
||||
cd dist/blenderbim/libs/site/packages/features/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcbimtester/features/template.html
|
||||
cd dist/blenderbim/libs/site/packages/features/steps/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcbimtester/features/steps/classification.py
|
||||
cd dist/blenderbim/libs/site/packages/features/steps/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcbimtester/features/steps/element_classes.py
|
||||
cd dist/blenderbim/libs/site/packages/features/steps/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcbimtester/features/steps/geocoding.py
|
||||
cd dist/blenderbim/libs/site/packages/features/steps/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcbimtester/features/steps/geolocation.py
|
||||
cd dist/blenderbim/libs/site/packages/features/steps/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcbimtester/features/steps/project_setup.py
|
||||
cd dist/blenderbim/libs/site/packages/features/steps/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcbimtester/features/steps/steps.py
|
||||
cd dist/blenderbim/libs/site/packages/features/steps/ && wget https://raw.githubusercontent.com/IfcOpenShell/IfcOpenShell/v0.6.0/src/ifcbimtester/features/steps/utils.py
|
||||
|
||||
# Required by IFCCOBie for XLSX support
|
||||
mkdir dist/working
|
||||
|
||||
Reference in New Issue
Block a user