Skip to content
Snippets Groups Projects
Commit 2bc9d38d authored by Daniel Nemergut's avatar Daniel Nemergut
Browse files

Merge branch 'ws1975-image_flagtemplate_rawdata' into 'main'

WS-1975 Image flagtemplate rawdata

See merge request !1640
parents ddc364d6 9d394e0c
No related branches found
No related tags found
2 merge requests!1669Catchup with main,!1640WS-1975 Image flagtemplate rawdata
......@@ -56,6 +56,7 @@ class GeneralFoundation(FoundationIF):
def __init__(self, parameters: dict, metadata: AbstractTextFile):
self.logger = logging.getLogger("casa_envoy")
self.parent_path = parameters["parent_path"]
self.rawdata_dir = self.parent_path / "rawdata"
self.working_dir = self.parent_path / "working"
self.content = json.loads(metadata.content)
......@@ -76,8 +77,21 @@ class GeneralFoundation(FoundationIF):
if stripped_file:
shutil.copy(stripped_file, self.working_dir)
self.copy_into_rawdata()
self.logger.info("General data foundation complete!")
def copy_into_rawdata(self):
"""
CASA expects some files from the 'working' directory to also exist next to the data in the 'rawdata' directory.
:return:
"""
# Copy files that need to exist next to the data into the rawdata directory
for file in Path(self.working_dir).glob('*flagtargetstemplate.txt'):
if Path(file).exists():
shutil.copy(file, self.rawdata_dir)
class RestoreFoundation(FoundationIF):
"""
......
......@@ -78,6 +78,19 @@ class TestGeneralFoundation:
general.data_foundation()
assert mock_copy.call_count == 2
@patch("pathlib.Path.glob", return_value=["TSKY0001_split.flagtargetstemplate.txt"])
@patch("pathlib.Path.exists", return_value=True)
@patch("shutil.copy")
def test_general_copy_into_rawdata(self, mock_copy, mock_exists, mock_glob):
general.copy_into_rawdata()
assert mock_exists.call_count == 1
assert mock_copy.call_count == 1
assert mock_glob.call_count == 1
# Ensure copy was called on the expected files
rawdata_dir_path = Path('/lustre/aoc/cluster/pipeline/docker/workspaces/spool/tmpo1ca1pp_/rawdata')
mock_copy.assert_any_call("TSKY0001_split.flagtargetstemplate.txt", rawdata_dir_path)
class TestRestoreFoundation:
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment