Skip to content

Commit

Permalink
Test URLconf building with invalid apps
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiask committed Sep 14, 2023
1 parent 8011171 commit e31f142
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/testapp/test_feincms3.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from contextlib import contextmanager
from types import SimpleNamespace

Expand All @@ -17,6 +18,7 @@
from feincms3.applications import (
ApplicationType,
PageTypeMixin,
_del_apps_urlconf_cache,
apps_urlconf,
reverse_any,
reverse_app,
Expand Down Expand Up @@ -414,8 +416,36 @@ def test_apps(self):

# The exact value of course does not matter, just the fact that the
# value does not change all the time.
_del_apps_urlconf_cache()
self.assertEqual(apps_urlconf(), "urlconf_fe9552a8363ece1f7fcf4970bf575a47")

updated = Page.objects.filter(page_type="blog").update(
page_type="invalid", app_namespace="invalid"
)
self.assertEqual(updated, 2)

_del_apps_urlconf_cache()
self.assertEqual(apps_urlconf(), "urlconf_4bacbaf40cbe7e198373fd8d629e819c")

# Blog and publications
self.assertEqual(
len(
sys.modules["urlconf_fe9552a8363ece1f7fcf4970bf575a47"]
.urlpatterns[0]
.url_patterns
),
2,
)
# Only publications, invalid apps are filtered out
self.assertEqual(
len(
sys.modules["urlconf_4bacbaf40cbe7e198373fd8d629e819c"]
.urlpatterns[0]
.url_patterns
),
1,
)

def _apps_validation_models(self, home_path=None):
home = Page.objects.create(
title="home",
Expand Down

0 comments on commit e31f142

Please sign in to comment.