Skip to content

Commit

Permalink
test: add assert statements in e2e tests, remove file with semicolons…
Browse files Browse the repository at this point in the history
… in filename (DEV-3219) (#756)
  • Loading branch information
jnussbaum committed Jan 23, 2024
1 parent 7adc837 commit 6311a45
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/dsp_tools/commands/xmlupload/resource_multimedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _upload_bitstream(
This function uploads a specified bitstream file to SIPI and then returns the file information from SIPI.
Args:
resource: resource with that has a bitstream
resource: resource that has a bitstream
sipi_server: server to upload
imgdir: directory of the file
permissions_lookup: dictionary that contains the permission name as string and the corresponding Python object
Expand Down
15 changes: 10 additions & 5 deletions test/e2e/commands/test_create_get_xmlupload.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,38 +44,41 @@ def tearDownClass(cls) -> None:

def test_create_project(self) -> None:
"""Test if the systematic JSON project file can be uploaded without producing an error on its way"""
create_project(
success = create_project(
project_file_as_path_or_parsed=self.test_project_systematic_file.absolute(),
server=self.server,
user_mail=self.user,
password=self.password,
verbose=True,
)
self.assertTrue(success)

def test_xml_upload_incremental(self) -> None:
"""
Test if the systematic XML data file can be uploaded without producing an error on its way,
and if the 'id2iri' replacement works, so that the 2nd upload works.
"""
xmlupload(
success = xmlupload(
input_file=self.test_data_systematic_file,
server=self.server,
user=self.user,
password=self.password,
imgdir=self.imgdir,
sipi=self.sipi,
)
self.assertTrue(success)

mapping_file = get_most_recent_glob_match("test-data-systematic_id2iri_mapping_*.json")
second_xml_file_orig = Path("testdata/id2iri/test-id2iri-data.xml")
id2iri(
success = id2iri(
xml_file=str(second_xml_file_orig),
json_file=str(mapping_file),
)
mapping_file.unlink()
self.assertTrue(success)

second_xml_file_replaced = get_most_recent_glob_match(f"{second_xml_file_orig.stem}_replaced_*.xml")
xmlupload(
success = xmlupload(
input_file=second_xml_file_replaced,
server=self.server,
user=self.user,
Expand All @@ -85,21 +88,23 @@ def test_xml_upload_incremental(self) -> None:
)
second_xml_file_replaced.unlink()
self.assertListEqual(list(Path(self.cwd).glob("stashed_*_properties_*.txt")), [])
self.assertTrue(success)

def test_get_project(self) -> None:
"""
Retrieve the systematic JSON project file with the "get" command,
and check if the result is identical to the original file.
"""
out_file = self.testdata_tmp / "_test-project-systematic.json"
get_project(
success = get_project(
project_identifier="systematic-tp",
outfile_path=str(out_file),
server=self.server,
user=self.user,
password=self.password,
verbose=True,
)
self.assertTrue(success)

project_original = self._get_original_project()
with open(out_file, encoding="utf-8") as f:
Expand Down
Binary file removed testdata/bitstreams/test;with;multiple;semicola.png
Binary file not shown.
10 changes: 0 additions & 10 deletions testdata/xml-data/test-data-systematic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -369,16 +369,6 @@
</text-prop>
</resource>

<resource label="Imagething-multiple-semicola"
restype=":ImageThing"
id="image_thing_10"
permissions="res-default">
<bitstream>testdata/bitstreams/test;with;multiple;semicola.png</bitstream>
<text-prop name=":hasSimpleText">
<text permissions="prop-default" encoding="utf8">This is a Imagething, the name has multiple semicola</text>
</text-prop>
</resource>

<region label="Polygon in image"
id="region_1"
permissions="res-restricted"
Expand Down

0 comments on commit 6311a45

Please sign in to comment.