From f6d1201534ca4149f21e58c7bd8e3a5906e2cbe8 Mon Sep 17 00:00:00 2001 From: Janet Goldstein <jgoldste@nrao.edu> Date: Tue, 27 Jul 2021 15:45:11 +0000 Subject: [PATCH] WS-543: fixed meaningful tests that had been disabled; discarded others --- .../ingest_envoy/test/test_manifest_if.py | 116 +++--------------- 1 file changed, 17 insertions(+), 99 deletions(-) diff --git a/apps/cli/executables/pexable/ingest_envoy/test/test_manifest_if.py b/apps/cli/executables/pexable/ingest_envoy/test/test_manifest_if.py index 33de61243..61d16291a 100644 --- a/apps/cli/executables/pexable/ingest_envoy/test/test_manifest_if.py +++ b/apps/cli/executables/pexable/ingest_envoy/test/test_manifest_if.py @@ -11,8 +11,6 @@ from pathlib import Path # pylint: disable=E0401, E0402, R1721, W0621 -import pytest - from ingest_envoy.ingestion_manifest import ( IngestionManifestBuilder, find_manifest, @@ -52,8 +50,7 @@ logger.addHandler(logging.StreamHandler(sys.stdout)) FAKE_LOCATOR = "uid://evla/calibration/doo-wah-ditty-ditty-af123" -# TODO: -@pytest.mark.skip("FIXME") + def test_filters_cal_input_files(ingest_path: Path): """ We'll be getting calibration/image/eb, etc. science products from a directory under @@ -101,8 +98,6 @@ def test_filters_cal_input_files(ingest_path: Path): shutil.rmtree(ingest_path) -# TODO: -@pytest.mark.skip("FIXME") def test_writes_expected_output_files(ingest_path: Path): """ Did the manifest builder produce the manifest file, the weblog, and the science product tar? @@ -132,8 +127,6 @@ def test_writes_expected_output_files(ingest_path: Path): shutil.rmtree(ingest_path) -# TODO: -@pytest.mark.skip("FIXME") def test_params_json_well_formed(): """ Make sure our ManifestParameters makes nice JSON @@ -153,17 +146,6 @@ def test_params_json_well_formed(): json.dumps(params_json) -@pytest.mark.skip("TODO") -def test_params_properly_formatted(): - """ - TODO - :return: - """ - raise NotImplementedError - - -# TODO: -@pytest.mark.skip("FIXME") def test_input_sp_well_formed(): """ Make sure our InputScienceProduct makes nice JSON @@ -180,8 +162,6 @@ def test_input_sp_well_formed(): assert sp_in.to_json() == sp_dict -# TODO: -@pytest.mark.skip("FIXME or get rid of me") def test_input_group_well_formed(): """ Make sure our InputGroup makes nice JSON @@ -189,39 +169,17 @@ def test_input_group_well_formed(): :return: """ sp1 = InputScienceProduct(locator="uid://evla/execblock/coffee_heath_bar_crunch_7a23f") - sp1_json = sp1.to_json() - sp2 = InputScienceProduct(locator="uid://evla/execblock/mint_oreo_omg_omg") - sp2_json = sp2.to_json() - - expected = { - IngestionManifestKey.INPUT_GROUP.value: { - IngestionManifestKey.SCIENCE_PRODUCTS.value: [sp1_json, sp2_json] - } - } - ingroup = InputGroup(science_products=[sp1, sp2]) - actual = ingroup.to_json() - - actual = actual[IngestionManifestKey.INPUT_GROUP.value] - expected = expected[IngestionManifestKey.INPUT_GROUP.value] - assert actual.keys() == expected.keys() - actual = actual[IngestionManifestKey.SCIENCE_PRODUCTS.value] - expected = expected[IngestionManifestKey.SCIENCE_PRODUCTS.value] - assert len(actual) == len(expected) == 2 - marvin = actual[0] - trillian = expected[0] - for key, _ in marvin.items(): - assert trillian[key] == marvin[key] + input_group = InputGroup(science_products=[sp1, sp2]) + assert IngestionManifestKey.SCIENCE_PRODUCTS.value in input_group.to_json().keys() - marvin = actual[1] - trillian = expected[1] - for key, _ in marvin.items(): - assert trillian[key] == marvin[key] + sps_found = input_group.science_products + assert len(sps_found) == 2 + assert sp1 in sps_found + assert sp2 in sps_found -# TODO: -@pytest.mark.skip("FIXME") def test_ancillary_product_well_formed(): """ The JSON shouldn't contain empty fields @@ -235,70 +193,30 @@ def test_ancillary_product_well_formed(): assert actual == expected -# TODO: -@pytest.mark.skip("FIXME or get rid of me") def test_output_group_well_formed(): """ Make sure our OutputScienceProduct makes nice JSON :return: """ - sp1 = OutputScienceProduct(type=ScienceProductType.IMAGE, filename="see_no_evil.fits") - sp2 = OutputScienceProduct(type=ScienceProductType.IMAGE, filename="hear_no_evil.fits") + osp = OutputScienceProduct( + type=ScienceProductType.EVLA_CAL, filename="im_a_lil_calibration.tar" + ) ap1 = AncillaryProduct( type=AncillaryProductType.PIPELINE_ARTIFACTS, filename="without_feathers.tar" ) ap2 = AncillaryProduct( type=AncillaryProductType.PIPELINE_ARTIFACTS, filename="with_feathers.tar" ) - opg = OutputGroup(science_products=[sp1, sp2], ancillary_products=[ap1, ap2]) - opg_json = opg.to_json() - dumped = json.dumps(opg_json) - - assert ( - dumped == '{"output_group": ' - '{"science_products": ' - '[{"type": "image", "filename": "see_no_evil.fits"}, ' - '{"type": "image", "filename": "hear_no_evil.fits"}], ' - '"ancillary_products": [{"type": "pipeline_artifacts", ' - '"filename": "without_feathers.tar"}, ' - '{"type": "pipeline_artifacts", "filename": "with_feathers.tar"}]}}' - ) - -@pytest.mark.skip("TODO, or maybe not") -def test_input_group_properly_formatted(): - """ - Does the InputGroup get written to the file in the expected format? - - :return: - """ - sp1 = InputScienceProduct(locator="uid://evla/execblock/coffee_heath_bar_crunch_7a23f") - - ingroup = InputGroup(science_products=[sp1]) - ig_dict = json.loads(ingroup.to_json()) - ig_text = json.dumps(ig_dict, indent=4) - expected = """ - "input_group": { - "science_products": [ - { - "locator": "uid://evla/execblock/coffee_heath_bar_crunch_7a23f" - } - ] - }, - """ - assert ig_text == expected - - -@pytest.mark.skip("TODO") -def test_output_group_properly_formatted(): - """ - TODO - Does the OutputGroup get written to the file in the expected format? + expected_json = { + IngestionManifestKey.SCIENCE_PRODUCTS.value: [osp.to_json()], + IngestionManifestKey.ANCILLARY_PRODUCTS.value: [ap1.to_json(), ap2.to_json()], + } + opg = OutputGroup(science_products=[osp], ancillary_products=[ap1, ap2]) + actual_json = opg.to_json() - :return: - """ - raise NotImplementedError + assert actual_json == expected_json def test_evla_cal_manifest_matches_example(ingest_path: Path): -- GitLab