Skip to content

Commit

Permalink
Fix default duration in purge command
Browse files Browse the repository at this point in the history
  • Loading branch information
replaceafill authored and sevein committed Jul 8, 2021
1 parent fef9899 commit 587aeab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
documents.
By default, this command only purges packages of a certain age. It uses
``--age='0 00:06:00'``, meaning that no packages will be removed if they have
``--age='0 06:00:00'``, meaning that no packages will be removed if they have
not completed processing more than six hours ago. Optionally, users can pass
other values.
``/manage.py purge_transient_processing_data --age='0 00:12:00'`` purges
``/manage.py purge_transient_processing_data --age='0 12:00:00'`` purges
packages that completed processing at least twelve hours ago.
``/manage.py purge_transient_processing_data --age=0`` can be used to target
Expand Down Expand Up @@ -81,13 +81,13 @@ def add_arguments(self, parser):
)
parser.add_argument(
"--age",
default="0 00:06:00",
default="0 06:00:00",
help=(
"Only purge packages of a certain age (completion date). "
"Supported formats are: "
'"%%d %%H:%%M:%%S.%%f" or ISO 8601 durations. '
'E.g. express "36 hours" as "1 12:00:00" or "P1DT12H". '
'Default value is "0 00:06:00", i.e. "6 hours".'
'Default value is "0 06:00:00", i.e. "6 hours".'
),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ def search_enabled(settings):

@pytest.fixture()
def old_transfer(transfer):
transfer.completed_at = timezone.now() - parse_duration("0 00:12:00")
transfer.completed_at = timezone.now() - parse_duration("0 12:00:00")
transfer.save()

return transfer


@pytest.fixture()
def old_sip(sip):
sip.completed_at = timezone.now() - parse_duration("0 00:12:00")
sip.completed_at = timezone.now() - parse_duration("0 12:00:00")
sip.save()

return sip
Expand Down Expand Up @@ -61,7 +61,7 @@ def test_purge_command_keeps_package_with_failed_status(search_disabled, old_tra

@pytest.mark.django_db
def test_purge_command_skips_recent_packages(search_disabled, transfer):
call_command("purge_transient_processing_data", "--age", "0 00:06:00")
call_command("purge_transient_processing_data", "--age", "0 06:00:00")

assert models.Transfer.objects.filter(pk=transfer.pk).count() == 1

Expand All @@ -70,7 +70,7 @@ def test_purge_command_skips_recent_packages(search_disabled, transfer):
def test_purge_command_removes_package_matching_age_criteria(
search_disabled, old_transfer
):
call_command("purge_transient_processing_data", "--age", "0 00:06:00")
call_command("purge_transient_processing_data", "--age", "0 06:00:00")

assert models.Transfer.objects.filter(pk=old_transfer.pk).count() == 0

Expand Down

0 comments on commit 587aeab

Please sign in to comment.