8000 chore: Added tests for GetAdminUrlForLanguage template tag by filipweidemann · Pull Request #8049 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

chore: Added tests for GetAdminUrlForLanguage template tag #8049

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

Merged
merged 14 commits into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion cms/tests/test_templatetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
PageUrl,
Placeholder,
)
from cms.templatetags.cms_admin import GetPreviewUrl, get_page_display_name
from cms.templatetags.cms_admin import GetAdminUrlForLanguage, GetPreviewUrl, get_page_display_name
from cms.templatetags.cms_js_tags import json_filter
from cms.templatetags.cms_tags import (
_get_page_by_untyped_arg,
Expand All @@ -43,6 +43,28 @@


class TemplatetagTests(CMSTestCase):
def test_admin_pagecontent_language_tab_urls(self):
# Same setup as in the templatetag test above
page = create_page('AdminURLTestPage English Content', 'nav_playground.html', 'en')
english_content = page.pagecontent_set(manager="admin_manager").first()
german_content = create_page_content("de", "AdminURLTestPage German Content", page)

# Try to fill the cache with partial data (this should not be possible)
page.get_content_obj(language='en') # should not affect admin template tag
page.get_admin_content(language='en') # Should fill the whole cache

request = RequestFactory().get('/')
request.current_page = page
template = """
{% load cms_tags cms_admin %}
{% get_admin_url_for_language page_obj 'en' %}
{% get_admin_url_for_language page_obj 'de' %}
{% get_admin_url_for_language page_obj 'fr' %}
"""
output = self.render_template_obj(template, {'page_obj': page}, request)
self.assertIn(f'/en/admin/cms/pagecontent/{english_content.pk}/change/', output)
self.assertIn(f'/en/admin/cms/pagecontent/{german_content.pk}/change/', output)
self.assertIn(f'/en/admin/cms/pagecontent/add/?cms_page={page.pk}&language=fr', output)

def test_get_preview_url(self):
"""The get_preview_url template tag returns the content preview url for its language:
Expand Down
0