diff --git a/src/ifcbimtester/bimtester/features/steps/aggregation.py b/src/ifcbimtester/bimtester/features/steps/aggregation.py index f3bbec37b8..e35373ae02 100644 --- a/src/ifcbimtester/bimtester/features/steps/aggregation.py +++ b/src/ifcbimtester/bimtester/features/steps/aggregation.py @@ -20,10 +20,15 @@ def step_impl(context): @given(u'a set of specific related elements taken from the file "{path_file}"') def step_impl(context, path_file): import csv + import os model = getattr(context, "model", None) if not model: context.model = TableModel() - with open(path_file, encoding="utf-8") as csvfile: + if context.config.userdata.get('path'): + path_file = os.path.join(context.config.userdata.get('path'), path_file) + if not os.path.exists(path_file): + assert False, "File {} not found".format(path_file) + with open(path_file, 'r', encoding="utf-8-sig") as csvfile: reader = csv.DictReader(csvfile) for row in reader: context.model.add_row(row["RelatedObjects"], row["RelatingGroup"]) diff --git a/src/ifcbimtester/bimtester/features/steps/ifcdata.py b/src/ifcbimtester/bimtester/features/steps/ifcdata.py index a6e69e2bf8..8a3b90beb7 100644 --- a/src/ifcbimtester/bimtester/features/steps/ifcdata.py +++ b/src/ifcbimtester/bimtester/features/steps/ifcdata.py @@ -1,4 +1,4 @@ -from behave import step +from behave import step, given from utils import IfcFile @@ -7,8 +7,7 @@ def step_impl(context, schema): try: IfcFile.load_schema(schema) except: - assert False - + assert False, f"The schema {schema} could not be loaded" @step('The IFC file "{file}" must be provided') def step_impl(context, file): @@ -17,6 +16,19 @@ def step_impl(context, file): except: assert False, f"The file {file} could not be loaded" +@given('The IFC file has been provided through an argument') +def step_impl(context): + try: + IfcFile.load(context.config.userdata.get("ifcfile")) + except: + assert False, f"The IFC {context.config.userdata.get('ifcfile')} file could not be loaded" + +@given('A file path has been provided through an argument') +def step_impl(context): + try: + assert context.config.userdata.get("path") + except: + assert False, f"The path {context.config.userdata.get('path')} could not be loaded" @step("IFC data must use the {schema} schema") def step_impl(context, schema):