test: use load.py for joj1
All checks were successful
build / build (pull_request) Successful in 2m38s
build / build (push) Successful in 2m41s

This commit is contained in:
张泊明518370910136 2025-03-04 21:53:56 -05:00
parent 25da08ecfc
commit 30fae62b67
GPG Key ID: D47306D7062CDA9D
2 changed files with 14 additions and 16 deletions

View File

@ -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")

View File

@ -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