mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +00:00
validation tests
This commit is contained in:
committed by
Thomas Krijnen
parent
3c2b25d923
commit
15b24d8ba4
@@ -297,61 +297,66 @@ class TestIfcValidation(unittest.TestCase):
|
|||||||
logger.addHandler(report)
|
logger.addHandler(report)
|
||||||
ids_file.validate(ifc_file, logger)
|
ids_file.validate(ifc_file, logger)
|
||||||
self.assertEqual(len(report.statements), 5)
|
self.assertEqual(len(report.statements), 5)
|
||||||
|
logger.handlers.pop()
|
||||||
|
|
||||||
# def test_validate_all_facets(self):
|
def test_validate_all_facets(self):
|
||||||
# #Those are true:
|
#Those are true:
|
||||||
# p1 = ids.property.create(location="any", propertyset="MySet", name="Param1", value="banan")
|
e = ids.entity.create(name="IfcWall")
|
||||||
# p2 = ids.property.create(location="any", propertyset="MySet", name="Param2", value=120.0)
|
p1 = ids.property.create(location="any", propertyset="MySet", name="Param1", value="banan")
|
||||||
# # p3 = ids.property.create(location="any", propertyset="Pset_WallCommon", name="LoadBearing", value=False)
|
p2 = ids.property.create(location="any", propertyset="MySet", name="Param2", value=120.0)
|
||||||
# # #Those are false:
|
p3 = ids.property.create(location="any", propertyset="Pset_WallCommon", name="LoadBearing", value=False)
|
||||||
# # p4 = ids.property.create(location="any", propertyset="MySet", name="Param1", value="orange")
|
#Those are false:
|
||||||
# # p5 = ids.property.create(location="any", propertyset="MySet", name="Param2", value=123.4)
|
p4 = ids.property.create(location="any", propertyset="MySet", name="Param1", value="orange")
|
||||||
# # p6 = ids.property.create(location="any", propertyset="Pset_WallCommon", name="LoadBearing", value=True)
|
p5 = ids.property.create(location="any", propertyset="MySet", name="Param2", value=123.4)
|
||||||
|
p6 = ids.property.create(location="any", propertyset="Pset_WallCommon", name="LoadBearing", value=True)
|
||||||
|
|
||||||
# i = ids.ids()
|
i = ids.ids()
|
||||||
# i.specifications.append(ids.specification(name="Test_Specification"))
|
i.specifications.append(ids.specification(name="Test_Specification"))
|
||||||
# i.specifications[0].add_applicability(p1)
|
i.specifications[0].add_applicability(e)
|
||||||
# i.specifications[0].add_requirement(p2)
|
i.specifications[0].add_requirement(p1)
|
||||||
# # i.specifications[0].add_requirement(p2)
|
i.specifications[0].add_requirement(p2)
|
||||||
# # i.specifications[0].add_requirement(p3)
|
i.specifications[0].add_requirement(p3)
|
||||||
# # i.specifications[0].add_requirement(p4)
|
i.specifications[0].add_requirement(p4)
|
||||||
# # i.specifications[0].add_requirement(p5)
|
i.specifications[0].add_requirement(p5)
|
||||||
# # i.specifications[0].add_requirement(p6)
|
i.specifications[0].add_requirement(p6)
|
||||||
|
|
||||||
|
report = ids.SimpleHandler(report_valid=True)
|
||||||
|
logger.addHandler(report)
|
||||||
|
|
||||||
|
i.validate(ifc_file, logger)
|
||||||
|
# TODO self.assertEqual(len(report.statements), 27) #there are 5 walls in the IFC, one passed 3 criteria, est should fail (27 failures)
|
||||||
|
logger.handlers.pop()
|
||||||
|
|
||||||
# report = ids.SimpleHandler()
|
|
||||||
# logger.addHandler(report)
|
|
||||||
# i.validate(ifc_file, logger)
|
|
||||||
# self.assertEqual(len(report.statements), 3) #three should fail
|
|
||||||
|
|
||||||
""" Validating IDS files with restrictions """
|
""" Validating IDS files with restrictions """
|
||||||
|
|
||||||
# def test_validate_restrictions_enumeration(self):
|
def test_validate_restrictions_enumeration(self):
|
||||||
# IDS_URL = os.path.join(os.path.dirname(__file__), "Sample-BIM-Files/IDS/", "IDS_Wall_needs_property_with_restriction_enumeration.xml")
|
IDS_URL = os.path.join(os.path.dirname(__file__), "Sample-BIM-Files/IDS/", "IDS_Wall_needs_property_with_restriction_enumeration.xml")
|
||||||
# ids_file = ids.ids.open(IDS_URL)
|
ids_file = ids.ids.open(IDS_URL)
|
||||||
# self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["name"]['simpleValue'], "Test_Parameter")
|
self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["name"]['simpleValue'], "Test_Parameter")
|
||||||
# self.assertEqual( [x['@value'] for x in ids_file.specifications[0].requirements.terms[0].node["value"]['restriction'][0]['enumeration'] ], ['testA', 'testB'])
|
self.assertEqual( [x['@value'] for x in ids_file.specifications[0].requirements.terms[0].node["value"]['restriction'][0]['enumeration'] ], ['testA', 'testB'])
|
||||||
# # TODO actual test of validation result
|
# TODO actual test of validation result
|
||||||
# # self.assertTrue( )
|
# self.assertTrue( )
|
||||||
|
|
||||||
# def test_validate_restrictions_boundsInclusive(self):
|
def test_validate_restrictions_boundsInclusive(self):
|
||||||
# IDS_URL = os.path.join(os.path.dirname(__file__), "Sample-BIM-Files/IDS/", "IDS_Wall_needs_property_with_restriction_bounds.xml")
|
IDS_URL = os.path.join(os.path.dirname(__file__), "Sample-BIM-Files/IDS/", "IDS_Wall_needs_property_with_restriction_bounds.xml")
|
||||||
# ids_file = ids.ids.open(IDS_URL)
|
ids_file = ids.ids.open(IDS_URL)
|
||||||
# self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["name"]['simpleValue'], "Test_Parameter")
|
self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["name"]['simpleValue'], "Test_Parameter")
|
||||||
# self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["value"]['restriction'][0]['minInclusive']['@value'], '0')
|
self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["value"]['restriction'][0]['minInclusive']['@value'], '0')
|
||||||
# # TODO actual test of validation result
|
# TODO actual test of validation result
|
||||||
# # self.assertTrue( )
|
# self.assertTrue( )
|
||||||
|
|
||||||
# def test_validate_restrictions_boundsExclusive(self):
|
def test_validate_restrictions_boundsExclusive(self):
|
||||||
# #TODO
|
#TODO
|
||||||
# pass
|
pass
|
||||||
|
|
||||||
# def test_validate_restrictions_pattern_simple(self):
|
def test_validate_restrictions_pattern_simple(self):
|
||||||
# IDS_URL = os.path.join(os.path.dirname(__file__), "Sample-BIM-Files/IDS/", "IDS_Wall_needs_property_with_restriction_pattern.xml")
|
IDS_URL = os.path.join(os.path.dirname(__file__), "Sample-BIM-Files/IDS/", "IDS_Wall_needs_property_with_restriction_pattern.xml")
|
||||||
# ids_file = ids.ids.open(IDS_URL)
|
ids_file = ids.ids.open(IDS_URL)
|
||||||
# self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["name"]['simpleValue'], "Test_Parameter")
|
self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["name"]['simpleValue'], "Test_Parameter")
|
||||||
# self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["value"]['restriction'][0]['pattern']['@value'], '[A-Z]{2,4}')
|
self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["value"]['restriction'][0]['pattern']['@value'], '[A-Z]{2,4}')
|
||||||
# # TODO actual test of validation result
|
# TODO actual test of validation result
|
||||||
# # self.assertTrue( )
|
# self.assertTrue( )
|
||||||
|
|
||||||
|
|
||||||
class TestIdsReporting(unittest.TestCase):
|
class TestIdsReporting(unittest.TestCase):
|
||||||
@@ -363,6 +368,8 @@ class TestIdsReporting(unittest.TestCase):
|
|||||||
logger.addHandler(report)
|
logger.addHandler(report)
|
||||||
ids_file.validate(ifc_file, logger)
|
ids_file.validate(ifc_file, logger)
|
||||||
self.assertEqual(len(report.statements), 5)
|
self.assertEqual(len(report.statements), 5)
|
||||||
|
logger.handlers.pop()
|
||||||
|
|
||||||
|
|
||||||
def test_bcf_report(self):
|
def test_bcf_report(self):
|
||||||
ids_file = ids.ids.open(IDS_URL)
|
ids_file = ids.ids.open(IDS_URL)
|
||||||
@@ -373,6 +380,7 @@ class TestIdsReporting(unittest.TestCase):
|
|||||||
my_bcfxml = bcfxml.load(fn)
|
my_bcfxml = bcfxml.load(fn)
|
||||||
topics = my_bcfxml.get_topics()
|
topics = my_bcfxml.get_topics()
|
||||||
self.assertEqual(len(topics), 5)
|
self.assertEqual(len(topics), 5)
|
||||||
|
logger.handlers.pop()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in New Issue
Block a user