From ccc01ad3ae40490b6f9a280db6e909a53551c7fd Mon Sep 17 00:00:00 2001 From: Alexander Todorov Date: Wed, 30 Aug 2023 23:58:05 +0300 Subject: [PATCH] Add test for collectstatic because of https://github.com/sehmaschine/django-grappelli/issues/1022 --- tcms/core/tests/test_collectstatic.py | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tcms/core/tests/test_collectstatic.py diff --git a/tcms/core/tests/test_collectstatic.py b/tcms/core/tests/test_collectstatic.py new file mode 100644 index 0000000000..22cf034493 --- /dev/null +++ b/tcms/core/tests/test_collectstatic.py @@ -0,0 +1,34 @@ +import tempfile + +from django.conf import settings +from django.core.management import call_command +from django.test import TestCase, override_settings +from parameterized import parameterized + + +class TestCollectstatic(TestCase): + """ + Test manage.py collectstatic --noinput --link + + with different versions of STATICFILES_STORAGE. See + https://github.com/sehmaschine/django-grappelli/issues/1022 + """ + + @parameterized.expand( + [ + "django.contrib.staticfiles.storage.StaticFilesStorage", + "django.contrib.staticfiles.storage.ManifestStaticFilesStorage", + "tcms.tests.storage.RaiseWhenFileNotFound", + ] + ) + def test_collect_static(self, storage): # pylint: disable=no-self-use + with override_settings( + STATICFILES_STORAGE=storage, + STATIC_ROOT=tempfile.mkdtemp(), + STATICFILES_DIRS=[ # pylint: disable=avoid-list-comprehension + dir + for dir in settings.STATICFILES_DIRS + if not dir.endswith("node_modules") + ], + ): + call_command("collectstatic", "--noinput", "--link")