/
test_generic_test_config.py
73 lines (61 loc) · 2.6 KB
/
test_generic_test_config.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
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
# 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.
from pathlib2 import Path
import os
import unittest
from pyiron.base.settings.generic import Settings
class TestConfigSettingsStatic(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.resource_path = (
Path(__file__)
.expanduser()
.resolve()
.absolute()
.as_posix()
.replace("\\", "/")
)
cls.test_config = Settings(
config={
"sql_file": "sqlite.db",
"project_paths": os.path.abspath(os.path.join(cls.resource_path, "../../../../..")),
"resource_paths": os.path.abspath(os.path.join(cls.resource_path, "../../../static")),
}
)
def test_get_config_from_environment(self):
config = self.test_config.get_config_from_environment(environment={"PYIRONSQLFILE": '/a/b/c',
"SYSTEM": 'linux'},
config={'user': 'pyiron'})
self.assertEqual(config['sql_file'], '/a/b/c')
self.assertEqual(config['user'], 'pyiron')
self.assertEqual(len(config), 2)
# def test_db_connection_name(self):
# self.assertEqual(self.test_config.db_connection_name, 'test')
#
# def test_db_connection_string(self):
# self.assertEqual(self.test_config.db_connection_string, 'sqlite:///sqlite.db')
#
# def test_db_connection_table(self):
# self.assertEqual(self.test_config.db_connection_table, 'jobs_pyiron')
# def test_db_translate_dict(self):
# self.assertEqual(self.test_config.db_translate_dict,
# {'test': {self.resource_path + '/': self.resource_path + '/'}})
# def test_db_name(self):
# self.assertEqual(self.test_config.db_name, 'test')
# def test_top_path(self):
# self.assertEqual(self.test_config.top_path(self.resource_path + '/test'),
# self.resource_path + '/')
def test_resource_paths(self):
self.assertEqual(
self.test_config.resource_paths,
[
os.path.abspath(
os.path.join(self.resource_path, "../../../static")
).replace("\\", "/")
],
)
def test_login_user(self):
self.assertEqual(self.test_config.login_user, "pyiron")
if __name__ == "__main__":
unittest.main()