From 7e0b457b33c4b6fbeea2c2a8d9ef5110e3ca539d Mon Sep 17 00:00:00 2001 From: Austin Macdonald Date: Wed, 19 Feb 2025 10:19:36 -0600 Subject: [PATCH] compare to LS_FIELD_CHOICES --- src/con_duct/suite/ls.py | 1 + test/test_schema.py | 41 +++++++++------------------------------- 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/src/con_duct/suite/ls.py b/src/con_duct/suite/ls.py index f4b6ff2..b54053a 100644 --- a/src/con_duct/suite/ls.py +++ b/src/con_duct/suite/ls.py @@ -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(): diff --git a/test/test_schema.py b/test/test_schema.py index ea01e77..530a5e5 100644 --- a/test/test_schema.py +++ b/test/test_schema.py @@ -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: @@ -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) @@ -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)