mirror of
https://github.com/django-components/django-components.git
synced 2025-12-03 20:00:02 +00:00
fix: make template_loader consider tuples for STATICFILES_DIRS (#489)
Co-authored-by: Juro Oravec <juraj.oravec.josefson@gmail.com>
This commit is contained in:
parent
085c60a8c9
commit
d18aefc629
2 changed files with 34 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
from pathlib import Path
|
||||
from unittest import mock
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from django.template.engine import Engine
|
||||
from django.urls import include, path
|
||||
|
|
@ -125,6 +126,29 @@ class TestBaseDir(BaseTestCase):
|
|||
self.assertEqual(sorted(dirs), sorted(expected))
|
||||
|
||||
|
||||
class TestStaticFilesDirs(BaseTestCase):
|
||||
def setUp(self):
|
||||
settings.STATICFILES_DIRS = [
|
||||
"components",
|
||||
("with_alias", "components"),
|
||||
("too_many", "items", "components"),
|
||||
("with_not_str_alias", 3),
|
||||
] # noqa
|
||||
|
||||
def tearDown(self) -> None:
|
||||
del settings.STATICFILES_DIRS # noqa
|
||||
|
||||
@patch("django_components.template_loader.logger.warning")
|
||||
def test_static_files_dirs(self, mock_warning: MagicMock):
|
||||
mock_warning.reset_mock()
|
||||
current_engine = Engine.get_default()
|
||||
Loader(current_engine).get_dirs()
|
||||
|
||||
warn_inputs = [warn.args[0] for warn in mock_warning.call_args_list]
|
||||
assert "Got <class 'tuple'> : ('too_many', 'items', 'components')" in warn_inputs[0]
|
||||
assert "Got <class 'int'> : 3" in warn_inputs[1]
|
||||
|
||||
|
||||
class TestFilepathToPythonModule(BaseTestCase):
|
||||
def test_prepares_path(self):
|
||||
self.assertEqual(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue