Implement new IDS schema 0.4.1 (#1623)

This commit is contained in:
ArturTomczak
2021-08-24 12:57:44 +02:00
committed by GitHub
parent cb4001b47b
commit 486eb4d9a0
4 changed files with 1341 additions and 350 deletions
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,232 @@
<!-- edited with XMLSpy v2021 rel. 3 (x64) -->
<!-- Version 0.4.1- July 26, 2021 - DRAFT -->
<!-- Most recent version available at: http://standards.buildingsmart.org/IDS -->
<xs:schema xmlns:ids="http://standards.buildingsmart.org/IDS" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://www.w3.org/2001/XMLSchema-instance" targetNamespace="http://standards.buildingsmart.org/IDS" elementFormDefault="qualified" attributeFormDefault="unqualified" version="0.4.1">
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
<xs:import namespace="http://www.w3.org/2001/XMLSchema" schemaLocation="https://www.w3.org/2001/XMLSchema.xsd"/>
<xs:import namespace="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://www.w3.org/2001/XMLSchema-instance"/>
<xs:element name="ids">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ids:idsType">
<xs:sequence>
<xs:element name="info">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="ifcversion">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="2.3.0.1"/>
<xs:enumeration value="4.0.2.1"/>
<xs:enumeration value="4.3.0.0"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="description" type="xs:string" minOccurs="0"/>
<xs:element name="author" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[^@]+@[^\.]+\..+"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="copyright" type="xs:string"/>
<xs:element name="version" type="xs:decimal"/>
<xs:element name="date" type="xs:date"/>
<xs:element name="purpose" type="xs:string" minOccurs="0"/>
<xs:element name="milestone" type="xs:string" minOccurs="0"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:complexType name="entityType">
<xs:sequence>
<xs:element name="name" type="ids:idsValue"/>
<xs:element name="predefinedtype" type="ids:idsValue" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="idsValue">
<xs:choice minOccurs="1">
<!-- place for potential additional rules for idsValue -->
<xs:element name="simpleValue" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element ref="xs:restriction" minOccurs="1" maxOccurs="unbounded"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="classificationType">
<xs:sequence maxOccurs="2">
<xs:element name="value" type="ids:idsValue"/>
<xs:element name="system" type="ids:idsValue" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="location" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="type"/>
<xs:enumeration value="instance"/>
<xs:enumeration value="any"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType name="applicabilityType">
<xs:sequence>
<xs:element name="entity" type="ids:entityType"/>
<xs:element name="classification" type="ids:classificationType" minOccurs="0"/>
<xs:element name="property" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ids:propertyType"/>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="material" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ids:materialType"/>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="systemType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="href" type="xs:anyURI" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="propertyType">
<xs:sequence>
<xs:element name="propertyset" type="ids:idsValue"/>
<xs:element name="name" type="ids:idsValue"/>
<xs:element name="value" type="ids:idsValue"/>
</xs:sequence>
<xs:attribute name="location" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="type"/>
<xs:enumeration value="instance"/>
<xs:enumeration value="any"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType name="materialType">
<xs:sequence>
<xs:element name="value" type="ids:idsValue"/>
</xs:sequence>
<xs:attribute name="location" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="type"/>
<xs:enumeration value="instance"/>
<xs:enumeration value="any"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType name="requirementsType">
<xs:sequence maxOccurs="unbounded">
<xs:element name="entity" type="ids:entityType" minOccurs="0">
<xs:annotation>
<xs:documentation>Make sure 'Name' value of requirements entity is the same as the 'applicability' node, or a wildcard (inclusive pattern).</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="classification" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ids:classificationType">
<xs:sequence>
<xs:element name="instructions" type="xs:string" minOccurs="0">
<xs:annotation>
<xs:documentation>Author of the IDS can leave instructions for the authors of the IFC. This text could/should be displayed in the BIM/IFC authoring tool.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="uri" type="xs:anyURI" use="optional"/>
<xs:attribute name="use" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="required"/>
<xs:enumeration value="optional"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="property" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ids:propertyType">
<xs:sequence>
<xs:element name="instructions" type="xs:string" minOccurs="0">
<xs:annotation>
<xs:documentation>Author of the IDS can leave instructions for the authors of the IFC. This text could/should be displayed in the BIM/IFC authoring tool.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="uri" type="xs:anyURI" use="optional"/>
<xs:attribute name="use" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="required"/>
<xs:enumeration value="optional"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
<xs:element name="material" minOccurs="0">
<xs:complexType>
<xs:complexContent>
<xs:extension base="ids:materialType">
<xs:sequence>
<xs:element name="instructions" type="xs:string" minOccurs="0">
<xs:annotation>
<xs:documentation>Author of the IDS can leave instructions for the authors of the IFC. This text could/should be displayed in the BIM/IFC authoring tool.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute name="uri" type="xs:anyURI" use="optional"/>
<xs:attribute name="use" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="required"/>
<xs:enumeration value="optional"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="specificationType">
<xs:sequence>
<xs:element name="applicability" type="ids:applicabilityType"/>
<xs:element name="requirements" type="ids:requirementsType"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="optional"/>
<xs:attribute name="necessity" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="required"/>
<xs:enumeration value="optional"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType name="idsType">
<xs:sequence>
<xs:element name="specification" type="ids:specificationType" minOccurs="1" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
+219 -34
View File
@@ -1,8 +1,16 @@
import unittest
import ids
# from ids import ids
import requests
import os
import logging
# from xmlschema.validators.exceptions import XMLSchemaChildrenValidationError
import ifcopenshell
from bcf import bcfxml
import tempfile
def read_web_file(URL):
@@ -11,62 +19,104 @@ def read_web_file(URL):
class TestIdsParsing(unittest.TestCase):
def test_basic_ids_parse(self):
"""Parsing basic IDS files"""
def test_parse_basic_ids(self):
IDS_URL = "https://raw.githubusercontent.com/atomczak/Sample-BIM-Files/main/IDS/IDS_Wall_needs_all_fields.xml"
ids_file = ids.ids.parse(read_web_file(IDS_URL))
ids_file = ids.ids.open(read_web_file(IDS_URL))
self.assertEqual(type(ids_file).__name__, "ids")
def test_entity_facet(self):
def test_parse_entity_facet(self):
IDS_URL = "https://raw.githubusercontent.com/atomczak/Sample-BIM-Files/main/IDS/IDS_Wall_needs_entity.xml"
ids_file = ids.ids.parse(read_web_file(IDS_URL))
self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["name"], "IfcWall")
ids_file = ids.ids.open(read_web_file(IDS_URL))
self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["name"]["simpleValue"], "IfcWall")
def test_predefinedtype_facet(self):
def test_parse_predefinedtype_facet(self):
IDS_URL = (
"https://raw.githubusercontent.com/atomczak/Sample-BIM-Files/main/IDS/IDS_Wall_needs_predefinedtype.xml"
)
ids_file = ids.ids.parse(read_web_file(IDS_URL))
self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["predefinedtype"], "CLADDING")
ids_file = ids.ids.open(read_web_file(IDS_URL))
self.assertEqual(
ids_file.specifications[0].requirements.terms[0].node["predefinedtype"]["simpleValue"], "CLADDING"
)
def test_property_facet(self):
def test_parse_property_facet(self):
IDS_URL = "https://raw.githubusercontent.com/atomczak/Sample-BIM-Files/main/IDS/IDS_Wall_needs_property.xml"
ids_file = ids.ids.parse(read_web_file(IDS_URL))
self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["propertyset"], "Test_PropertySet")
self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["name"], "Test_Parameter")
self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["value"], "Test_Value")
ids_file = ids.ids.open(read_web_file(IDS_URL))
self.assertEqual(
ids_file.specifications[0].requirements.terms[0].node["propertyset"]["simpleValue"], "Test_PropertySet"
)
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"]["simpleValue"], "Test_Value")
def test_material_facet(self):
def test_parse_material_facet(self):
IDS_URL = "https://raw.githubusercontent.com/atomczak/Sample-BIM-Files/main/IDS/IDS_Wall_needs_material.xml"
ids_file = ids.ids.parse(read_web_file(IDS_URL))
self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["value"], "Test_Material")
ids_file = ids.ids.open(read_web_file(IDS_URL))
self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["value"]["simpleValue"], "Test_Material")
def test_classification_facet(self):
def test_parse_classification_facet(self):
IDS_URL = (
"https://raw.githubusercontent.com/atomczak/Sample-BIM-Files/main/IDS/IDS_Wall_needs_classification.xml"
)
ids_file = ids.ids.parse(read_web_file(IDS_URL))
self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["value"], "Test_Classification")
self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["system"], "Test_System")
ids_file = ids.ids.open(read_web_file(IDS_URL))
self.assertEqual(
ids_file.specifications[0].requirements.terms[0].node["value"]["simpleValue"], "Test_Classification"
)
self.assertEqual(ids_file.specifications[0].requirements.terms[0].node["system"]["simpleValue"], "Test_System")
""" Parsing invalid IDS.xml """
# TODO
# def test_invalid_classification_facet(self):
# IDS_URL = "https://raw.githubusercontent.com/atomczak/Sample-BIM-Files/main/IDS/Invalid_IDS_Wall_needs_classification.xml"
# self.assertRaises( XMLSchemaChildrenValidationError, ids.parse(read_web_file(IDS_URL)) )
# self.assertRaises( XMLSchemaChildrenValidationError, ids.open(read_web_file(IDS_URL)) )
""" Saving parsed IDS to IDS.xml """
def test_parsed_ids_to_xml(self):
IDS_URL = "https://raw.githubusercontent.com/atomczak/Sample-BIM-Files/main/IDS/IDS_Wall_needs_all_fields.xml"
ids_file = ids.ids.parse(read_web_file(IDS_URL))
ids_file = ids.ids.open(read_web_file(IDS_URL))
fn = "TEST_FILE.xml"
result = ids_file.to_xml(fn)
os.remove(fn)
self.assertTrue(result)
""" Parsing IDS files with restrictions """
def test_parse_restrictions_enumeration(self):
IDS_URL = "https://raw.githubusercontent.com/atomczak/Sample-BIM-Files/main/IDS/IDS_Wall_needs_property_with_restriction_enumeration.xml"
ids_file = ids.ids.open(read_web_file(IDS_URL))
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"],
)
def test_parse_restrictions_bounds(self):
IDS_URL = "https://raw.githubusercontent.com/atomczak/Sample-BIM-Files/main/IDS/IDS_Wall_needs_property_with_restriction_bounds.xml"
ids_file = ids.ids.open(read_web_file(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["value"]["restriction"][0]["minInclusive"]["@value"],
"0",
)
def test_parse_restrictions_pattern_simple(self):
IDS_URL = "https://raw.githubusercontent.com/atomczak/Sample-BIM-Files/main/IDS/IDS_Wall_needs_property_with_restriction_pattern.xml"
ids_file = ids.ids.open(read_web_file(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["value"]["restriction"][0]["pattern"]["@value"],
"[A-Z]{2,4}",
)
class TestIdsAuthoring(unittest.TestCase):
"""Creating basic IDS"""
def test_entity_create(self):
e = ids.entity.create(name="Test_Name", predefinedtype="Test_PredefinedType")
self.assertEqual(e.name, "Test_Name")
@@ -96,11 +146,6 @@ class TestIdsAuthoring(unittest.TestCase):
s = ids.specification(name="Test_Specification")
self.assertEqual(s.name, "Test_Specification")
def test_ids_create(self):
i = ids.ids()
self.assertEqual(i.specifications, [])
self.assertEqual(i.info, None)
def test_ids_add_content(self):
i = ids.ids()
i.specifications.append(ids.specification(name="Test_Specification"))
@@ -115,6 +160,55 @@ class TestIdsAuthoring(unittest.TestCase):
i.specifications[0].add_requirement(m)
self.assertEqual(i.specifications[0].requirements.terms[1].value, "Test_Value")
""" Creating IDS with restrictions """
def test_create_restrictions_enumeration(self):
i = ids.ids()
i.specifications.append(ids.specification(name="Test_Specification"))
i.specifications[0].add_applicability(ids.entity.create(name="Test_Name"))
r = ids.restriction.create(options=["testA", "testB"], type="enumeration", base="string")
m = ids.material.create(location="any", value=r)
i.specifications[0].add_requirement(m)
self.assertEqual(i.specifications[0].requirements.terms[0].value, "testA")
self.assertEqual(i.specifications[0].requirements.terms[0].value, "testB")
self.assertNotEqual(i.specifications[0].requirements.terms[0].value, "testC")
def test_create_restrictions_bounds(self):
i = ids.ids()
i.specifications.append(ids.specification(name="Test_Specification"))
i.specifications[0].add_applicability(ids.entity.create(name="Test_Name"))
r = ids.restriction.create(options={"minInclusive": 0, "maxExclusive": 10}, type="bounds", base="integer")
p = ids.property.create(location="any", propertyset="Test", name="Test", value=r)
i.specifications[0].add_requirement(p)
self.assertEqual(i.specifications[0].requirements.terms[0].value, 0)
self.assertEqual(i.specifications[0].requirements.terms[0].value, 5)
self.assertNotEqual(i.specifications[0].requirements.terms[0].value, -1)
self.assertNotEqual(i.specifications[0].requirements.terms[0].value, 10)
def test_create_restrictions_pattern_simple(self):
i = ids.ids()
i.specifications.append(ids.specification(name="Test_Specification"))
i.specifications[0].add_applicability(ids.entity.create(name="Test_Name"))
r = ids.restriction.create(options="[A-Z]{2,4}", type="pattern", base="string")
p = ids.property.create(location="any", propertyset="Test", name="Test", value=r)
i.specifications[0].add_requirement(p)
self.assertEqual(i.specifications[0].requirements.terms[0].value, "XYZ")
self.assertNotEqual(i.specifications[0].requirements.terms[0].value, "abc")
self.assertNotEqual(i.specifications[0].requirements.terms[0].value, "ABCDE")
self.assertNotEqual(i.specifications[0].requirements.terms[0].value, "A")
def test_create_restrictions_pattern_advanced(self):
i = ids.ids()
i.specifications.append(ids.specification(name="Test_Specification"))
i.specifications[0].add_applicability(ids.entity.create(name="Test_Name"))
# r = ids.restriction.create(options="^(Wanddurchbruch.*|Deckendurchbruch.*)", type="pattern", base="string")
r = ids.restriction.create(options="(Wanddurchbruch|Deckendurchbruch).*", type="pattern", base="string")
p = ids.property.create(location="any", propertyset="Test", name="Test", value=r)
i.specifications[0].add_requirement(p)
self.assertEqual(i.specifications[0].requirements.terms[0].value, "Wanddurchbruch")
self.assertEqual(i.specifications[0].requirements.terms[0].value, "Deckendurchbruch")
self.assertNotEqual(i.specifications[0].requirements.terms[0].value, "Deeckendurchbruch")
""" Saving created IDS to IDS.xml """
def test_created_ids_to_xml(self):
@@ -123,25 +217,116 @@ class TestIdsAuthoring(unittest.TestCase):
e = ids.entity.create(name="Test_Name", predefinedtype="Test_PredefinedType")
c = ids.classification.create(location="any", value="Test_Value", system="Test_System")
m = ids.material.create(location="any", value="Test_Value")
p = ids.property.create(location="any", propertyset="Test_PropertySet", name="Test_Parameter", value="Test_Value")
re = ids.restriction.create(options=["testA", "testB"], type="enumeration", base="string")
rb = ids.restriction.create(options={"minInclusive": 0, "maxExclusive": 10}, type="bounds", base="integer")
rp = ids.restriction.create(options="[A-Z]{2,4}", type="pattern", base="string")
p1 = ids.property.create(location="any", propertyset="Test_PropertySet", name="Test_Parameter", value=re)
p2 = ids.property.create(location="any", propertyset="Test_PropertySet", name="Test_Parameter", value=rb)
p3 = ids.property.create(location="any", propertyset="Test_PropertySet", name="Test_Parameter", value=rp)
p4 = ids.property.create(
location="any", propertyset="Test_PropertySet", name="Test_Parameter", value=[re, rb, rp]
)
i.specifications[0].add_applicability(e)
i.specifications[0].add_applicability(m)
i.specifications[0].add_requirement(c)
i.specifications[0].add_requirement(p)
i.specifications[0].add_requirement(p1)
i.specifications[0].add_requirement(p2)
i.specifications[0].add_requirement(p3)
i.specifications[0].add_requirement(p4)
fn = "TEST_FILE.xml"
result = i.to_xml(fn)
os.remove(fn)
self.assertTrue(result)
""" IDS information """
def test_create_full_information(self):
i = ids.ids(
ifcversion="2.3.0.1",
description="test",
author="test@test.com",
copyright="test",
version=1.23,
creation_date="2021-01-01",
purpose="test",
milestone="test",
)
self.assertEqual(i.info["version"], 1.23)
class TestIfcValidation(unittest.TestCase):
pass
# TODO
def test_validate_simple(self):
# TODO
pass
def test_validate_all_facets(self):
# TODO
pass
""" Validating IDS files with restrictions """
# def test_validate_restrictions_enumeration(self):
# IDS_URL = "https://raw.githubusercontent.com/atomczak/Sample-BIM-Files/main/IDS/IDS_Wall_needs_property_with_restriction_enumeration.xml"
# ids_file = ids.ids.open(read_web_file(IDS_URL))
# 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'])
# # TODO actual test of validation result
# # self.assertTrue( )
# def test_validate_restrictions_boundsInclusive(self):
# IDS_URL = "https://raw.githubusercontent.com/atomczak/Sample-BIM-Files/main/IDS/IDS_Wall_needs_property_with_restriction_bounds.xml"
# ids_file = ids.ids.open(read_web_file(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["value"]['restriction'][0]['minInclusive']['@value'], '0')
# # TODO actual test of validation result
# # self.assertTrue( )
# def test_validate_restrictions_boundsExclusive(self):
# #TODO
# pass
# def test_validate_restrictions_pattern_simple(self):
# IDS_URL = "https://raw.githubusercontent.com/atomczak/Sample-BIM-Files/main/IDS/IDS_Wall_needs_property_with_restriction_pattern.xml"
# ids_file = ids.ids.open(read_web_file(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["value"]['restriction'][0]['pattern']['@value'], '[A-Z]{2,4}')
# # TODO actual test of validation result
# # self.assertTrue( )
class TestIdsResults(unittest.TestCase):
pass
# TODO
class TestIdsReporting(unittest.TestCase):
TEST_PATH = os.getcwd()
IFC_URL = "https://raw.githubusercontent.com/atomczak/Sample-BIM-Files/main/IFC/IFC4_Wall_3_with_properties.ifc"
IDS_URL = "https://raw.githubusercontent.com/atomczak/Sample-BIM-Files/main/IDS/IDS_Wall_needs_all_fields.xml"
logger = logging.getLogger("IDS_Logger")
# logging.basicConfig(level=logging.INFO, format="%(message)s")
# logging.basicConfig(filename=TEST_PATH+r"\log.txt", level=logging.INFO, format="%(message)s")
content = read_web_file(IFC_URL)
file = open(TEST_PATH + r"\test.ifc", "w")
file.write(content)
file.close()
ifc_file = ifcopenshell.open(TEST_PATH + r"\test.ifc")
os.remove(TEST_PATH + r"\test.ifc")
def test_simple_report(self):
ids_file = ids.ids.open(read_web_file(self.IDS_URL))
report = ids.SimpleHandler()
self.logger.addHandler(report)
ids_file.validate(self.ifc_file, self.logger)
self.assertEqual(len(report.statements), 5)
def test_bcf_report(self):
ids_file = ids.ids.open(read_web_file(self.IDS_URL))
fn = tempfile.gettempdir() + r"\bcf_test.bcfzip"
bcf_handler = ids.BcfHandler(project_name="Default IDS Project", author="your@email.com", filepath=fn)
self.logger.addHandler(bcf_handler)
ids_file.validate(self.ifc_file, self.logger)
my_bcfxml = bcfxml.load(fn)
topics = my_bcfxml.get_topics()
self.assertEqual(len(topics), 5)
if __name__ == "__main__":