Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a couple of tests for collectstatic. #9589

Merged
merged 1 commit into from Jan 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion tests/staticfiles_tests/test_management.py
Expand Up @@ -15,7 +15,7 @@
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.utils import timezone
Expand Down Expand Up @@ -237,6 +237,12 @@ 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):
self.run_collectstatic()
with mock.patch('builtins.input', side_effect=lambda _: 'no'):
with self.assertRaisesMessage(CommandError, 'Collecting static files cancelled'):
call_command('collectstatic', interactive=True)


class TestCollectionExcludeNoDefaultIgnore(TestDefaults, CollectionTestCase):
"""
Expand Down Expand Up @@ -467,3 +473,8 @@ 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):
with self.assertRaisesMessage(CommandError, "Can't symlink to a remote destination."):
self.run_collectstatic()