Skip to content

Commit

Permalink
Added a couple of tests for collectstatic.
Browse files Browse the repository at this point in the history
  • Loading branch information
atombrella committed Jan 15, 2018
1 parent 02365d3 commit 7a7aec7
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions tests/staticfiles_tests/test_management.py
Expand Up @@ -15,9 +15,9 @@
collectstatic, runserver,
)
from django.core.exceptions import ImproperlyConfigured
from django.core.management import call_command
from django.core.management import CommandError, call_command
from django.test import override_settings
from django.test.utils import extend_sys_path
from django.test.utils import captured_stdout, extend_sys_path
from django.utils import timezone
from django.utils._os import symlinks_supported
from django.utils.functional import empty
Expand Down Expand Up @@ -237,6 +237,13 @@ def test_no_warning_for_empty_staticdir(self):
self.assertNotIn(self.delete_warning_msg, output)
self.assertIn(self.files_copied_msg, output)

def test_cancelled(self):
msg = 'Collecting static files cancelled'
self.run_collectstatic()
with mock.patch('builtins.input', side_effect=lambda _: 'no'):
with self.assertRaisesMessage(CommandError, msg):
call_command('collectstatic', interactive=True)


class TestCollectionExcludeNoDefaultIgnore(TestDefaults, CollectionTestCase):
"""
Expand Down Expand Up @@ -467,3 +474,9 @@ def test_clear_broken_symlink(self):
os.symlink(nonexistent_file_path, broken_symlink_path)
self.run_collectstatic(clear=True)
self.assertFalse(os.path.lexists(broken_symlink_path))

@override_settings(STATICFILES_STORAGE='staticfiles_tests.storage.PathNotImplementedStorage')
def test_no_remote_link(self):
msg = "Can't symlink to a remote destination."
with self.assertRaisesMessage(CommandError, msg):
self.run_collectstatic()

0 comments on commit 7a7aec7

Please sign in to comment.