Skip to content

Commit

Permalink
compare to LS_FIELD_CHOICES
Browse files Browse the repository at this point in the history
  • Loading branch information
asmacdo committed Feb 19, 2025
1 parent 5731b28 commit 7e0b457
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 32 deletions.
1 change: 1 addition & 0 deletions src/con_duct/suite/ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def process_run_data(
return output_rows


# TODO(asmacdo) move to util BEFORE merge
def _flatten_dict(d: Dict[str, Any]) -> Dict[str, Any]:
items: List[tuple[str, Any]] = []
for k, v in d.items():
Expand Down
41 changes: 9 additions & 32 deletions test/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,8 @@
import os
from pathlib import Path
from con_duct.__main__ import Arguments, execute
from con_duct.suite.ls import _flatten_dict


#
# TEST_SCRIPT = str(Path(__file__).with_name("data") / "test_script.py")
#
# expected_files = [
# SUFFIXES["stdout"],
# SUFFIXES["stderr"],
# SUFFIXES["info"],
# SUFFIXES["usage"],
# ]
#
#
# def assert_expected_files(temp_output_dir: str, exists: bool = True) -> None:
# assert_files(temp_output_dir, expected_files, exists=exists)
def write_list_to_file(items, path: Path):
with path.open("w") as f:
for item in items:
f.write(f"{item}\n")


def read_list_from_file(path: Path):
with path.open("r") as f:
return [line.strip() for line in f]
from con_duct.suite.ls import LS_FIELD_CHOICES, _flatten_dict
from con_duct.utils import SCHEMA_DIR, read_list_from_file, write_list_to_file


def test_info_fields() -> None:
Expand All @@ -35,22 +12,21 @@ def test_info_fields() -> None:
Fails when schema changes-- commit the new version and bump schema version
"""
SCHEMA_TEST = "test/data/schema_test/"
args = Arguments.from_argv(
["echo", "hello", "world"],
sample_interval=4.0,
report_interval=60.0,
output_prefix=SCHEMA_TEST,
output_prefix=SCHEMA_DIR,
clobber=True,
)
# Execute duct
assert execute(args) == 0 # exit_code
os.remove(Path(SCHEMA_TEST, "stdout"))
os.remove(Path(SCHEMA_TEST, "stderr"))
os.remove(Path(SCHEMA_TEST, "usage.json"))
info_file = Path(SCHEMA_TEST, "info.json")
os.remove(Path(SCHEMA_DIR, "stdout"))
os.remove(Path(SCHEMA_DIR, "stderr"))
os.remove(Path(SCHEMA_DIR, "usage.json"))
info_file = Path(SCHEMA_DIR, "info.json")

info_fields_schema_file = Path(SCHEMA_TEST, "info_schema.txt")
info_fields_schema_file = Path(SCHEMA_DIR, "info_schema.txt")

expected_info_fields_schema = read_list_from_file(info_fields_schema_file)

Expand All @@ -59,3 +35,4 @@ def test_info_fields() -> None:

write_list_to_file(actual_info_schema, info_fields_schema_file)
assert set(expected_info_fields_schema) == set(actual_info_schema)
assert set(expected_info_fields_schema) == set(LS_FIELD_CHOICES)

0 comments on commit 7e0b457

Please sign in to comment.