test: use load.py for joj1
This commit is contained in:
parent
25da08ecfc
commit
30fae62b67
|
@ -37,7 +37,7 @@ def convert_joj1(yaml_path: Path, toml_path: Path) -> None:
|
|||
logger.info(f"Converting yaml file {yaml_path}")
|
||||
joj1_model = load_joj1_yaml(yaml_path)
|
||||
task_model = convert_joj1_conf(joj1_model)
|
||||
result_dict = task_model.model_dump(by_alias=True, exclude_none=True)
|
||||
result_dict = task_model.model_dump(mode="json", by_alias=True, exclude_none=True)
|
||||
toml_path.write_text(rtoml.dumps(result_dict))
|
||||
|
||||
|
||||
|
@ -65,7 +65,9 @@ def convert(
|
|||
)
|
||||
repo_conf, task_conf = load_joj3_toml(root, repo_toml_path, task_toml_path)
|
||||
result_model = convert_conf(repo_conf, task_conf)
|
||||
result_dict = result_model.model_dump(by_alias=True, exclude_none=True)
|
||||
result_dict = result_model.model_dump(
|
||||
mode="json", by_alias=True, exclude_none=True
|
||||
)
|
||||
with result_json_path.open("w") as result_file:
|
||||
json.dump(result_dict, result_file, ensure_ascii=False, indent=4)
|
||||
result_file.write("\n")
|
||||
|
|
|
@ -1,23 +1,19 @@
|
|||
from pathlib import Path
|
||||
from typing import Any, Dict, Tuple
|
||||
|
||||
import rtoml
|
||||
import yaml
|
||||
|
||||
from joj3_config_generator.convert import convert_joj1
|
||||
from joj3_config_generator.models import joj1
|
||||
|
||||
|
||||
def read_convert_joj1_files(case_name: str) -> Tuple[joj1.Config, Dict[str, Any]]:
|
||||
root = Path(__file__).resolve().parent
|
||||
task_yaml_path = root / case_name / "task.yaml"
|
||||
task_yaml = task_yaml_path.read_text()
|
||||
task_toml_path = root / case_name / "task.toml"
|
||||
task_toml = task_toml_path.read_text()
|
||||
return joj1.Config(**yaml.safe_load(task_yaml)), rtoml.loads(task_toml)
|
||||
from joj3_config_generator.load import load_joj1_yaml
|
||||
|
||||
|
||||
def load_case(case_name: str) -> None:
|
||||
joj1, expected_result = read_convert_joj1_files(case_name)
|
||||
result = convert_joj1(joj1).model_dump(by_alias=True, exclude_none=True)
|
||||
root = Path(__file__).resolve().parent
|
||||
task_yaml_path = root / case_name / "task.yaml"
|
||||
task_yaml = load_joj1_yaml(task_yaml_path)
|
||||
task_toml_path = root / case_name / "task.toml"
|
||||
task_toml = task_toml_path.read_text()
|
||||
expected_result = rtoml.loads(task_toml)
|
||||
result = convert_joj1(task_yaml).model_dump(
|
||||
mode="json", by_alias=True, exclude_none=True
|
||||
)
|
||||
assert result == expected_result
|
||||
|
|
Loading…
Reference in New Issue
Block a user