Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/tests/common.py
Show First 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | def check_archive(archive_name: str, archive_name_to_check: str): | ||||
"""Helper function to ensure archive_name is present within the | """Helper function to ensure archive_name is present within the | ||||
archive_name_to_check. | archive_name_to_check. | ||||
Raises: | Raises: | ||||
AssertionError if archive_name is not present within | AssertionError if archive_name is not present within | ||||
archive_name_to_check | archive_name_to_check | ||||
""" | """ | ||||
if "." in archive_name: | pattern = re.compile(".*/.*_%s" % archive_name) | ||||
filename, extension = archive_name.split(".") | |||||
pattern = re.compile(".*/%s.*\\.%s" % (filename, extension)) | |||||
else: | |||||
pattern = re.compile(".*/%s" % archive_name) | |||||
assert pattern.match(archive_name_to_check) is not None | assert pattern.match(archive_name_to_check) is not None |