Skip to content

Commit

Permalink
#99 test for error message on too old django version
Browse files Browse the repository at this point in the history
  • Loading branch information
ephes committed Aug 12, 2023
1 parent ff616ae commit 98bd340
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cast/management/commands/media_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def handle(self, *args, **options):
if not DJANGO_VERSION_VALID:
# make sure we run at least Django 4.2
print("Django version >= 4.2 is required")
exit(1)
return
try:
production_storage, backup_storage = storages["production"], storages["backup"]
except InvalidStorageError:
Expand Down
8 changes: 8 additions & 0 deletions tests/management_command_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ def test_media_backup_without_storages(capsys, settings):
call_command("media_backup")
captured = capsys.readouterr()
assert captured.out == "production or backup storage not configured\n"


def test_media_backup_without_django_version(capsys, settings, mocker):
settings.STORAGES = {}
mocker.patch("cast.management.commands.media_backup.DJANGO_VERSION_VALID", False)
call_command("media_backup")
captured = capsys.readouterr()
assert captured.out == "Django version >= 4.2 is required\n"

0 comments on commit 98bd340

Please sign in to comment.