-
Notifications
You must be signed in to change notification settings - Fork 14
/
project_test.py
47 lines (35 loc) · 1.34 KB
/
project_test.py
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
import os
import shutil
import tempfile
import unittest
import pyvista
import omfvista
DATA_FILE = os.path.join(os.path.dirname(__file__), "../assets/test_file.omf")
class TestProjectIO(unittest.TestCase):
"""
Test the wrapper for a project file which will iterate over all data types.
This will then save out a ``pyvista.MultiBlockDataSet`` and reload it
"""
def setUp(self):
self.test_dir = tempfile.mkdtemp()
self.project_filename = os.path.join(self.test_dir, "project.vtm")
def tearDown(self):
# Remove the test data directory after the test
shutil.rmtree(self.test_dir)
def test_load_project(self):
"""Test loading a sample project file"""
data = omfvista.load_project(DATA_FILE)
self.assertIsNotNone(data)
self.assertTrue(isinstance(data, pyvista.MultiBlock))
self.assertEqual(data.n_blocks, 9)
# def test_save_project(self):
# """Test saving a sample project file in the VTK format"""
# data = omfvista.load_project(DATA_FILE)
# data.save(self.project_filename)
# # And reload that project
# data = pyvista.read(self.project_filename)
# self.assertTrue(isinstance(data, pyvista.MultiBlock))
# self.assertEqual(data.n_blocks, 9)
if __name__ == "__main__":
import unittest
unittest.main()