From 59b1aaa5a5136702f5b7b2ab718d91128473b9c3 Mon Sep 17 00:00:00 2001 From: Mads Jensen <mje@inducks.org> Date: Mon, 15 Jan 2018 13:37:03 +0100 Subject: [PATCH] Added a couple tests for collectstatic. --- tests/staticfiles_tests/test_management.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/staticfiles_tests/test_management.py b/tests/staticfiles_tests/test_management.py index 54c271b793..a6db5ef1c5 100644 --- a/tests/staticfiles_tests/test_management.py +++ b/tests/staticfiles_tests/test_management.py @@ -15,7 +15,7 @@ from django.contrib.staticfiles.management.commands import ( 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 @@ -237,6 +237,12 @@ class TestInteractiveMessages(CollectionTestCase): 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): """ @@ -467,3 +473,8 @@ class TestCollectionLinks(TestDefaults, CollectionTestCase): 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()