-
-
Notifications
You must be signed in to change notification settings - Fork 965
Expand file tree
/
Copy pathtest_write.py
More file actions
73 lines (55 loc) · 2.73 KB
/
Copy pathtest_write.py
File metadata and controls
73 lines (55 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# IfcOpenShell - IFC toolkit and geometry engine
# Copyright (C) 2021 Thomas Krijnen <thomas@aecgeeks.com>
#
# This file is part of IfcOpenShell.
#
# IfcOpenShell is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# IfcOpenShell is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import tempfile
from pathlib import Path
import pytest
import ifcopenshell
TEST_FILE_DIR = Path(__file__).parent / "../../../test/input/"
class TestWrite:
model: ifcopenshell.file
def setup_method(self):
self.model = ifcopenshell.open(TEST_FILE_DIR / "WallInstance_IFC4Add2.ifc")
def assert_model_is_written(self, filename, format=None, zipped=False):
with tempfile.TemporaryDirectory() as temp_dir:
file_path = Path(temp_dir) / filename
self.model.write(file_path, format, zipped)
assert file_path.exists()
def test_write_ifcspf(self):
self.assert_model_is_written("model.ifc")
@pytest.mark.skip(reason="IFCXML writing not supported")
def test_write_ifcxml(self):
self.assert_model_is_written("model.ifcXML")
@pytest.mark.skip(reason="IFCXML writing not supported")
def test_write_ifc_zip_ifcxml_format(self):
self.assert_model_is_written("model.ifcZIP", format=".ifcXML", zipped=True)
def test_write_ifc_zip_ifcspf_format(self):
self.assert_model_is_written("model.ifcZIP")
def test_write_zip(self):
self.assert_model_is_written("model.zip", format=".ifcZIP")
def test_write_anyextension_ifcspf_format(self):
self.assert_model_is_written("model.anyextension", format=".ifc")
def test_write_anyextension_ifczip_ifcspf_format(self):
self.assert_model_is_written("model.anyextension", format=".ifc", zipped=True)
@pytest.mark.skip(reason="IFCXML writing not supported")
def test_write_anyextension_ifcxml_format(self):
self.assert_model_is_written("model.anyextension", format=".ifcXML")
@pytest.mark.skip(reason="IFCXML writing not supported")
def test_write_anyextension_ifczip_ifcxml_format(self):
self.assert_model_is_written("model.anyextension", format=".ifcXML", zipped=True)
def test_write_to_non_existing_dir(self):
self.assert_model_is_written("tmp/model.ifczip")