|
1 | 1 | """Test the pytest fixtures."""
|
2 | 2 |
|
| 3 | +from pathlib import Path |
| 4 | + |
| 5 | +from aiida.manage.configuration import get_config, load_config |
| 6 | +from aiida.manage.configuration.settings import DEFAULT_CONFIG_FILE_NAME |
| 7 | + |
3 | 8 |
|
4 | 9 | def test_aiida_config(tmp_path_factory):
|
5 | 10 | """Test that ``aiida_config`` fixture is loaded by default and creates a config instance in temp directory."""
|
6 |
| - from aiida.manage.configuration import get_config |
7 |
| - from aiida.manage.configuration.config import Config |
| 11 | + from aiida.manage.configuration import CONFIG |
| 12 | + |
| 13 | + config = get_config(create=False) |
| 14 | + assert config is CONFIG |
| 15 | + assert config.dirpath.startswith(str(tmp_path_factory.getbasetemp())) |
| 16 | + assert Path(config.dirpath, DEFAULT_CONFIG_FILE_NAME).is_file() |
| 17 | + assert config._default_profile |
| 18 | + |
8 | 19 |
|
9 |
| - config = get_config() |
10 |
| - assert isinstance(config, Config) |
| 20 | +def test_aiida_config_file(tmp_path_factory): |
| 21 | + """Test that ``aiida_config`` fixture stores the configuration in a config file in a temp directory.""" |
| 22 | + # Unlike get_config, load_config always loads the configuration from a file |
| 23 | + config = load_config(create=False) |
11 | 24 | assert config.dirpath.startswith(str(tmp_path_factory.getbasetemp()))
|
| 25 | + assert Path(config.dirpath, DEFAULT_CONFIG_FILE_NAME).is_file() |
| 26 | + assert config._default_profile |
12 | 27 |
|
13 | 28 |
|
14 | 29 | def test_aiida_config_tmp(aiida_config_tmp, tmp_path_factory):
|
|
0 commit comments