Files
IfcOpenShell/src/ifcopenshell-python/test/global_id_updates.py
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
592 B
Python
Raw Normal View History

2022-10-05 13:07:16 +02:00
import pytest
import ifcopenshell
2024-05-08 17:21:00 +05:00
import ifcopenshell.guid
2022-10-05 13:07:16 +02:00
def test_global_id_updates():
g1, g2, g3 = (ifcopenshell.guid.new() for i in range(3))
f = ifcopenshell.file()
2024-07-26 12:00:28 +10:00
2022-10-05 13:07:16 +02:00
f.createIfcWall(g1)
f[g1].GlobalId = g2
with pytest.raises(RuntimeError):
f[g1]
assert f[g2]
2024-07-26 12:00:28 +10:00
2022-10-05 13:07:16 +02:00
inst = f.createIfcWall()
inst.GlobalId = g3
assert f[g3]
2024-07-26 12:00:28 +10:00
2022-10-05 13:07:16 +02:00
# Non-unique guid, succeeds but logs an error
ifcopenshell.get_log()
inst = f.createIfcWall(g3)
assert "Overwriting" in ifcopenshell.get_log()
2024-07-26 12:00:28 +10:00
2022-10-05 13:07:16 +02:00
if __name__ == "__main__":
pytest.main(["-sx", __file__])