test: allow non-exist toml file input
All checks were successful
build / build (push) Successful in 2m36s
All checks were successful
build / build (push) Successful in 2m36s
This commit is contained in:
parent
2bf1a225b6
commit
bddb67decf
|
@ -1,5 +1,5 @@
|
||||||
import json
|
import json
|
||||||
import os
|
from pathlib import Path
|
||||||
from typing import Any, Dict, Tuple
|
from typing import Any, Dict, Tuple
|
||||||
|
|
||||||
import rtoml
|
import rtoml
|
||||||
|
@ -11,19 +11,17 @@ from joj3_config_generator.models import repo, task
|
||||||
def read_convert_files(
|
def read_convert_files(
|
||||||
case_name: str,
|
case_name: str,
|
||||||
) -> Tuple[repo.Config, task.Config, Dict[str, Any]]:
|
) -> Tuple[repo.Config, task.Config, Dict[str, Any]]:
|
||||||
root = os.path.dirname(os.path.realpath(__file__))
|
root = Path(__file__).resolve().parent
|
||||||
repo_toml_path = os.path.join(root, case_name, "repo.toml")
|
repo_toml_path = root / case_name / "repo.toml"
|
||||||
with open(repo_toml_path) as f:
|
repo_toml = repo_toml_path.read_text() if repo_toml_path.exists() else ""
|
||||||
repo_toml = f.read()
|
task_toml_path = root / case_name / "task.toml"
|
||||||
task_toml_path = os.path.join(root, case_name, "task.toml")
|
task_toml = task_toml_path.read_text() if task_toml_path.exists() else ""
|
||||||
with open(task_toml_path) as f:
|
result = json.loads((root / case_name / "task.json").read_text())
|
||||||
task_toml = f.read()
|
return (
|
||||||
result_json_path = os.path.join(root, case_name, "task.json")
|
repo.Config(**rtoml.loads(repo_toml)),
|
||||||
with open(result_json_path) as f:
|
task.Config(**rtoml.loads(task_toml)),
|
||||||
result: Dict[str, Any] = json.load(f)
|
result,
|
||||||
repo_obj = rtoml.loads(repo_toml)
|
)
|
||||||
task_obj = rtoml.loads(task_toml)
|
|
||||||
return repo.Config(**repo_obj), task.Config(**task_obj), result
|
|
||||||
|
|
||||||
|
|
||||||
def load_case(case_name: str) -> None:
|
def load_case(case_name: str) -> None:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import os
|
from pathlib import Path
|
||||||
from typing import Any, Dict, Tuple
|
from typing import Any, Dict, Tuple
|
||||||
|
|
||||||
import rtoml
|
import rtoml
|
||||||
|
@ -9,16 +9,12 @@ from joj3_config_generator.models import joj1
|
||||||
|
|
||||||
|
|
||||||
def read_convert_joj1_files(case_name: str) -> Tuple[joj1.Config, Dict[str, Any]]:
|
def read_convert_joj1_files(case_name: str) -> Tuple[joj1.Config, Dict[str, Any]]:
|
||||||
root = os.path.dirname(os.path.realpath(__file__))
|
root = Path(__file__).resolve().parent
|
||||||
task_yaml_path = os.path.join(root, case_name, "task.yaml")
|
task_yaml_path = root / case_name / "task.yaml"
|
||||||
with open(task_yaml_path) as f:
|
task_yaml = task_yaml_path.read_text()
|
||||||
task_yaml = f.read()
|
task_toml_path = root / case_name / "task.toml"
|
||||||
task_toml_path = os.path.join(root, case_name, "task.toml")
|
task_toml = task_toml_path.read_text()
|
||||||
with open(task_toml_path) as f:
|
return joj1.Config(**yaml.safe_load(task_yaml)), rtoml.loads(task_toml)
|
||||||
task_toml = f.read()
|
|
||||||
joj1_obj = yaml.safe_load(task_yaml)
|
|
||||||
task_obj = rtoml.loads(task_toml)
|
|
||||||
return joj1.Config(**joj1_obj), task_obj
|
|
||||||
|
|
||||||
|
|
||||||
def load_case(case_name: str) -> None:
|
def load_case(case_name: str) -> None:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user