-
Notifications
You must be signed in to change notification settings - Fork 62
/
test_settings.py
42 lines (26 loc) · 1.14 KB
/
test_settings.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
import json
import os
from pathlib import PosixPath
from random import random
from emmet.core.settings import EmmetSettings
def test_default_config_path(tmp_path: PosixPath):
"""Make sure the default config path works"""
rand_symprec = random()
with open(tmp_path / "temp_config.json", "w") as f:
json.dump({"SYMPREC": rand_symprec}, f)
os.environ["EMMET_CONFIG_FILE"] = str(tmp_path.resolve() / "temp_config.json")
test_config = EmmetSettings()
assert test_config.SYMPREC == rand_symprec
def test_allow_extra_fields(tmp_path: PosixPath):
"""Makes sure emmet config can be subclassed without loading issues"""
with open(tmp_path / "temp_config.json", "w") as f:
json.dump({"sub_class_prop": True}, f)
os.environ["EMMET_CONFIG_FILE"] = str(tmp_path.resolve() / "temp_config.json")
EmmetSettings()
def test_from_url():
"""Makes sure loading from a URL Works"""
os.environ[
"EMMET_CONFIG_FILE"
] = "https://raw.githubusercontent.com/materialsproject/emmet/master/tests/emmet-core/test_settings.json"
test_config = EmmetSettings()
assert test_config.ANGLE_TOL == 1.0