From 90d0144a0805a61a1fe375f7869a8147762e7056 Mon Sep 17 00:00:00 2001 From: "Janet L. Goldstein" <jgoldste@nrao.edu> Date: Tue, 3 Aug 2021 15:06:38 -0600 Subject: [PATCH] WS-601: build the ingestion artifacts tar filename only once --- .../ingest_envoy/ingestion_manifest.py | 2 +- .../test/test_evla_cal_manifest.py | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/ingestion_manifest.py b/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/ingestion_manifest.py index 282cea855..1aded5b16 100644 --- a/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/ingestion_manifest.py +++ b/apps/cli/executables/pexable/ingest_envoy/ingest_envoy/ingestion_manifest.py @@ -203,7 +203,7 @@ class IngestionManifestBuilder: manifest.output_group.ancillary_products.append(artifacts_ap) manifest_file = manifest.write() - artifacts_file = self.staging_source_dir / self._build_artifacts_filename() + artifacts_file = self.staging_source_dir / artifacts_filename self.write_ingestion_artifacts_tar(artifacts_file) return manifest, manifest_file diff --git a/apps/cli/executables/pexable/ingest_envoy/test/test_evla_cal_manifest.py b/apps/cli/executables/pexable/ingest_envoy/test/test_evla_cal_manifest.py index ef74962af..81d122d09 100644 --- a/apps/cli/executables/pexable/ingest_envoy/test/test_evla_cal_manifest.py +++ b/apps/cli/executables/pexable/ingest_envoy/test/test_evla_cal_manifest.py @@ -7,6 +7,8 @@ import sys from pathlib import Path # pylint: disable=E0401, E0402, R1721, W0621 +from unittest.mock import patch + import pytest import tarfile @@ -227,6 +229,31 @@ def test_output_group_well_formed(): assert actual_json == expected_json +def test_ingestion_artifacts_tar_filename_built_just_once(ingest_path: Path): + """ + We run into trouble if manifest builder's _build_artifacts_filename() + is called more than once. + + :param ingest_path: + :return: + """ + populate_fake_evla_cal_ingest_path(ingest_path) + with patch( + "ingest_envoy.ingestion_manifest.IngestionManifestBuilder._build_artifacts_filename", + return_value="ingestion_artifacts_mine_mine_mine.tar", + ) as mock: + # build the manifest + IngestionManifestBuilder( + staging_source_dir=ingest_path, + sp_type=ScienceProductType.EVLA_CAL.value, + locator="uid://evla/calibration/are-we-there-yet", + telescope=Telescope.EVLA.value, + ).build() + mock.assert_called_once() + + shutil.rmtree(ingest_path) + + def test_ingestion_artifacts_tar_correct(ingest_path: Path): """ Do we build the correct ingestion_artifacts tar for for standard imaging ingestion? @@ -256,6 +283,8 @@ def test_ingestion_artifacts_tar_correct(ingest_path: Path): mf_path = Path(member.name) assert mf_path.name == MANIFEST_FILENAME + shutil.rmtree(ingest_path) + def test_evla_cal_manifest_matches_example(ingest_path: Path): """ -- GitLab