Skip to content
Snippets Groups Projects
Commit 46159c81 authored by Charlotte Hausman's avatar Charlotte Hausman
Browse files

- fix tests to not really write out changes to the test files

- fix typos
parent 2dc76467
No related branches found
No related tags found
2 merge requests!1607merge 2.8.3 to main,!1583add formatting to relative path correction for numerical values
Pipeline #14363 passed
......@@ -150,7 +150,7 @@ class AuditFiles(AuditorIF):
def format_relative_path(relative_path: str) -> str:
"""
Occasionally (very very very occasionally) the relative path might be numerical only.
CASA hates this and falls over (see WS-2113). If the relative path is numerical enclose it in quotes
CASA hates this and falls over (see WS-2116). If the relative path is numerical enclose it in quotes
:param relative_path: the relative path to check
:return: relative path string, corrected if necessary
......
......@@ -137,7 +137,7 @@
</ProcessingCommand>
</ProcessingProcedure>
<DataSet>
<RelativePath>'1234567'</RelativePath>
<RelativePath>1234567</RelativePath>
<SdmIdentifier>brain_001.58099.678886747686</SdmIdentifier>
<DataType>asdm</DataType>
</DataSet>
......
......@@ -186,15 +186,18 @@ class TestAuditFiles:
result2F = audit_files.check_required_fields(test_ppr, fields2F)
assert result2F is False
@patch("builtins.open")
@patch("os.chdir")
@patch("shutil.copy")
def test_correct_for_condor(self, mock_copy, mock_os):
def test_correct_for_condor(self, mock_copy, mock_os, mock_open):
ppr = AuditFiles([test_cal_metadata, test_ppr], cal_settings).correct_for_condor(ppr=test_ppr)
assert mock_open.call_count == 1 # would this have written out as expected if not mocked?
assert ppr.filename == "test/input_files/PPR.xml"
@patch("builtins.open")
@patch("os.chdir")
@patch("shutil.copy")
def test_correct_for_condor_numerical_path(self, mock_copy, mock_os):
def test_correct_for_condor_numerical_path(self, mock_copy, mock_os, mock_open):
cal_settings_num = cal_settings.copy()
cal_settings_num["ppr"] = "test/input_files/PPR-numerical-path.xml"
cal_settings_num["processingDirectory"] = "1234567"
......@@ -202,7 +205,7 @@ class TestAuditFiles:
ppr=test_ppr_numerical
)
correct_content = Path("test/input_files/PPR-numerical-path-correct.xml").read_text()
# print(ppr.content)
assert mock_open.call_count == 1 # would this have written out as expected if not mocked?
assert ppr.content == correct_content
def test_audit(self):
......
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