83 lines
2.6 KiB
Python
83 lines
2.6 KiB
Python
import pathlib
|
|
|
|
from kalpaa.config import MeasurementTypeEnum
|
|
import kalpaa.config.config_reader
|
|
|
|
|
|
TEST_DATA_DIR = pathlib.Path(__file__).resolve().parent / "test_files"
|
|
|
|
|
|
def test_parse_general_config_dict():
|
|
general_config_dict = {
|
|
"dots_json_name": "test_dots.json",
|
|
"indexes_json_name": "test_indexes.json",
|
|
"out_dir_name": "test_out",
|
|
"log_pattern": "%(asctime)s | %(process)d | %(levelname)-7s | %(name)s:%(lineno)d | %(message)s",
|
|
"measurement_type": "x-electric-field",
|
|
"root_directory": "test_root",
|
|
"mega_merged_name": "test_mega_merged.csv",
|
|
"mega_merged_inferenced_name": "test_mega_merged_inferenced.csv",
|
|
"skip_to_stage": 1,
|
|
}
|
|
|
|
general_config = kalpaa.config.config_reader.read_general_config_dict(
|
|
general_config_dict
|
|
)
|
|
|
|
expected_general_config = kalpaa.config.GeneralConfig(
|
|
dots_json_name="test_dots.json",
|
|
indexes_json_name="test_indexes.json",
|
|
out_dir_name="test_out",
|
|
log_pattern="%(asctime)s | %(process)d | %(levelname)-7s | %(name)s:%(lineno)d | %(message)s",
|
|
measurement_type=MeasurementTypeEnum.X_ELECTRIC_FIELD,
|
|
root_directory=pathlib.Path("test_root"),
|
|
mega_merged_name="test_mega_merged.csv",
|
|
mega_merged_inferenced_name="test_mega_merged_inferenced.csv",
|
|
skip_to_stage=1,
|
|
)
|
|
|
|
assert general_config == expected_general_config
|
|
|
|
|
|
def test_parse_empty_general_config_dict():
|
|
general_config_dict = {}
|
|
|
|
general_config = kalpaa.config.config_reader.read_general_config_dict(
|
|
general_config_dict
|
|
)
|
|
|
|
expected_general_config = kalpaa.config.GeneralConfig(
|
|
dots_json_name="dots.json",
|
|
indexes_json_name="indexes.json",
|
|
out_dir_name="out",
|
|
log_pattern="%(asctime)s | %(process)d | %(levelname)-7s | %(name)s:%(lineno)d | %(message)s",
|
|
measurement_type=MeasurementTypeEnum.X_ELECTRIC_FIELD,
|
|
root_directory=pathlib.Path.cwd(),
|
|
mega_merged_name="mega_merged_coalesced.csv",
|
|
mega_merged_inferenced_name="mega_merged_coalesced_inferenced.csv",
|
|
skip_to_stage=None,
|
|
)
|
|
|
|
assert general_config == expected_general_config
|
|
|
|
|
|
def test_parse_config_toml(snapshot):
|
|
test_config_file = TEST_DATA_DIR / "test_config.toml"
|
|
actual_config = kalpaa.config.config_reader.read_config(test_config_file)
|
|
|
|
assert actual_config == snapshot
|
|
|
|
|
|
def test_parse_config_all_fields_toml(snapshot):
|
|
test_config_file = TEST_DATA_DIR / "test_config_all_fields.toml"
|
|
actual_config = kalpaa.config.config_reader.read_config(test_config_file)
|
|
|
|
assert actual_config == snapshot
|
|
|
|
|
|
def test_parse_config_few_fields_toml(snapshot):
|
|
test_config_file = TEST_DATA_DIR / "test_config_few_fields.toml"
|
|
actual_config = kalpaa.config.config_reader.read_config(test_config_file)
|
|
|
|
assert actual_config == snapshot
|