/
test_hdf5content.py
48 lines (40 loc) · 1.63 KB
/
test_hdf5content.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
48
# coding: utf-8
# Copyright (c) Max-Planck-Institut für Eisenforschung GmbH - Computational Materials Design (CM) Department
# Distributed under the terms of "New BSD License", see the LICENSE file.
import unittest
import os
from pyiron_base.project.generic import Project
from pyiron_base._tests import PyironTestCase
class DatabasePropertyIntegration(PyironTestCase):
@classmethod
def setUpClass(cls):
cls.file_location = os.path.dirname(os.path.abspath(__file__))
cls.project = Project(os.path.join(cls.file_location, "hdf5_content"))
cls.ham = cls.project.create_job('ScriptJob', "job_test_run")
cls.ham.save()
@classmethod
def tearDownClass(cls):
project = Project(
os.path.join(os.path.dirname(os.path.abspath(__file__)), "hdf5_content")
)
ham = project.load(project.get_job_ids()[0])
ham.remove()
project.remove(enable=True)
def test_inspect_job(self):
job_inspect = self.project.inspect(self.ham.job_name)
self.assertIsNotNone(job_inspect)
self.assertEqual(
job_inspect.content.input.__repr__(), job_inspect["input"].__repr__()
)
self.assertEqual(
sorted(dir(job_inspect.content.input)),
sorted(job_inspect["input"].list_nodes()
+ job_inspect["input"].list_groups())
)
def test_setitem(self):
self.ham['user/output/some_value'] = 0.3
self.assertEqual(self.ham['user/output/some_value'], 0.3)
with self.assertRaises(ValueError):
self.ham['input/value'] = 1
if __name__ == "__main__":
unittest.main()