repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
django-cms
cms/test_utils/project/objectpermissionsapp/models.py
.py
from django.conf import settings from django.contrib.auth.models import Permission from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ValidationError from django.db import models from django.utils.translation imp...
61
2,596
django-cms
cms/test_utils/project/templates/inner_dir/custom_templates_2/__init__.py
.py
from django.utils.translation import gettext_lazy as _ TEMPLATES = { 'right_col_two.html': _('Two columns'), 'right_col_three.html': _('Three columns'), }
7
164
django-cms
cms/test_utils/project/nested_plugins_app/cms_plugins.py
.py
from cms.plugin_base import CMSPluginBase from cms.plugin_pool import plugin_pool class PlanetPlugin(CMSPluginBase): """ The contents of this plugin are never rendered. Only render the toolbar entries. """ parent_classes = ['SolarSystemPlugin'] render_template = 'nested_plugins_app/planet.html...
23
605
django-cms
cms/test_utils/project/sampleapp/admin.py
.py
from django.contrib import admin from cms.admin.placeholderadmin import FrontendEditableAdminMixin from cms.admin.utils import GrouperModelAdmin from cms.test_utils.project.sampleapp.models import ( Category, GrouperModel, Picture, SampleAppConfig, SimpleGrouperModel, SomeEditableModel, ) cla...
47
1,306
django-cms
cms/test_utils/project/sampleapp/urls_excluded.py
.py
from django.urls import include, re_path urlpatterns = [ re_path(r'^excluded/', include('cms.test_utils.project.sampleapp.urls_example', namespace="excluded")), re_path(r'^not_excluded/', include('cms.test_utils.project.sampleapp.urls_example', namespace="not_excluded")), ]
7
284
django-cms
cms/test_utils/project/sampleapp/cms_apps.py
.py
from django.core.exceptions import ObjectDoesNotExist from django.http import HttpResponse from django.urls import re_path, reverse from django.utils.translation import gettext_lazy as _ from cms.app_base import CMSApp from cms.apphook_pool import apphook_pool from cms.test_utils.project.sampleapp.cms_menus import ( ...
152
4,437
django-cms
cms/test_utils/project/sampleapp/urls_extra.py
.py
from django.urls import re_path from . import views urlpatterns = [ re_path(r'extra_2/$', views.extra_view, {'message': 'test included urlconf'}, name='extra_second'), ]
8
176
django-cms
cms/test_utils/project/sampleapp/cms_toolbars.py
.py
from django.utils.translation import gettext_lazy as _ from cms.cms_toolbars import ADMIN_MENU_IDENTIFIER, ADMINISTRATION_BREAK from cms.toolbar.items import Break from cms.toolbar_base import CMSToolbar from cms.toolbar_pool import toolbar_pool from cms.utils.urlutils import admin_reverse SAMPLEAPP_BREAK = 'Sample A...
33
1,146
django-cms
cms/test_utils/project/sampleapp/cms_wizards.py
.py
from cms.test_utils.project.sampleapp.forms import SampleWizardForm from cms.wizards.wizard_base import Wizard class SampleWizard(Wizard): pass sample_wizard = SampleWizard( title="Sample", weight=105, form=SampleWizardForm, description="Create a new Sample", )
15
286
django-cms
cms/test_utils/project/sampleapp/models.py
.py
from functools import cached_property from django.db import models from django.urls import reverse from cms.models.fields import PlaceholderRelationField from cms.utils.mptree import get_tree_base from cms.utils.placeholder import get_placeholder_from_slot MP_Node = get_tree_base() class Category(MP_Node): par...
136
3,301
django-cms
cms/test_utils/project/sampleapp/cms_config.py
.py
from cms.app_base import CMSAppConfig from cms.test_utils.project.sampleapp.cms_wizards import sample_wizard class SampleAppConfig(CMSAppConfig): cms_enabled = True cms_wizards = [sample_wizard]
8
205
django-cms
cms/test_utils/project/sampleapp/views.py
.py
# Create your views here. from django.http import Http404 from django.shortcuts import render from django.utils.translation import gettext_lazy as _ from django.views.decorators.csrf import csrf_exempt from django.views.generic.base import TemplateView from cms.test_utils.project.sampleapp.models import Category from ...
79
2,443
django-cms
cms/test_utils/project/sampleapp/urls_sample_config.py
.py
from django.urls import re_path from . import views urlpatterns = [ re_path(r'^$', views.sample_view, {'message': 'sample root page', }, name='sample-config-root'), ]
8
173
django-cms
cms/test_utils/project/sampleapp/cms_menus.py
.py
from django.urls import NoReverseMatch, reverse from django.utils.translation import gettext_lazy as _ from cms.menu_bases import CMSAttachMenu from cms.test_utils.project.sampleapp.models import Category from menus.base import Menu, NavigationNode from menus.menu_pool import menu_pool class SampleAppMenu(Menu): ...
83
2,469
django-cms
cms/test_utils/project/sampleapp/urls.py
.py
from django.urls import include, re_path from django.utils.translation import gettext_lazy as _ from . import views """ Also used in cms.tests.ApphooksTestCase """ urlpatterns = [ re_path(r'^$', views.sample_view, {'message': 'sample root page', }, name='sample-root'), re_path(r'^exempt/$', views.exempt_view,...
23
1,337
django-cms
cms/test_utils/project/sampleapp/urls2.py
.py
from django.urls import re_path from . import views urlpatterns = [ re_path(r'^$', views.sample_view, {'message': 'sample apphook2 root page', }, name='sample2-root'), ]
8
176
django-cms
cms/test_utils/project/sampleapp/ns_urls.py
.py
from django.urls import re_path from django.utils.translation import gettext_lazy as _ from . import views urlpatterns = [ re_path(r'^current-app/$', views.current_app, name='current-app'), re_path(_('page'), views.current_app, name='translated-url'), ]
10
264
django-cms
cms/test_utils/project/sampleapp/urls_childapp.py
.py
from django.urls import re_path from cms.test_utils.project.sampleapp import views urlpatterns = [ re_path(r'^(?P<path>.+)$', views.childapp_view, name='childapp_view'), ]
8
178
django-cms
cms/test_utils/project/sampleapp/urls_example.py
.py
from django.urls import re_path from ..placeholderapp import views app_name = 'example_app' urlpatterns = [ re_path(r'^example/$', views.example_view, name="example"), ]
10
177
django-cms
cms/test_utils/project/sampleapp/urls_parentapp.py
.py
from django.urls import re_path from cms.test_utils.project.sampleapp import views urlpatterns = [ re_path(r'^(?P<path>.+)$', views.parentapp_view, name='parentapp_view'), ]
8
180
django-cms
cms/test_utils/project/sampleapp/forms.py
.py
from django import forms from django.contrib.auth.forms import AuthenticationForm from cms.test_utils.project.sampleapp.models import Category class LoginForm(AuthenticationForm): pass class LoginForm2(AuthenticationForm): pass class LoginForm3(AuthenticationForm): def __init__(self, request=None, *a...
25
493
django-cms
cms/test_utils/project/extensionapp/admin.py
.py
from django.contrib import admin from cms.extensions import PageContentExtensionAdmin, PageExtensionAdmin from cms.test_utils.project.extensionapp.models import ( MyPageContentExtension, MyPageExtension, ) class MyPageExtensionAdmin(PageExtensionAdmin): pass admin.site.register(MyPageExtension, MyPageE...
22
483
django-cms
cms/test_utils/project/extensionapp/cms_toolbars.py
.py
from django.urls import NoReverseMatch from django.utils.translation import gettext_lazy as _ from cms.test_utils.project.extensionapp.models import ( MyPageContentExtension, MyPageExtension, ) from cms.toolbar_base import CMSToolbar from cms.toolbar_pool import toolbar_pool from cms.utils.page_permissions imp...
76
3,003
django-cms
cms/test_utils/project/extensionapp/models.py
.py
from django.conf import settings from django.db import models from cms.extensions import PageContentExtension, PageExtension from cms.extensions.extension_pool import extension_pool class MyPageExtension(PageExtension): extra = models.CharField(blank=True, default='', max_length=255) favorite_users = models....
48
1,593
django-cms
cms/test_utils/fixtures/menus.py
.py
from cms.api import create_page class MenusFixture: def create_fixtures(self): """ Tree from fixture: + P1 | + P2 | + P3 + P4 | + P5 + P6 (not in menu) + P7 + P8 """ defaults = { ...
133
4,615
django-cms
cms/test_utils/fixtures/navextenders.py
.py
from cms.api import create_page from cms.models.pagemodel import Page class NavextendersFixture: def create_fixtures(self): """ Tree from fixture: page1 page2 page3 page4 page5 """ defaults = { ...
29
940
django-cms
cms/test_utils/fixtures/fakemlng.py
.py
from cms.api import add_plugin from cms.test_utils.project.fakemlng.models import MainModel, Translations class FakemlngFixtures: def create_fixtures(self): main = MainModel.objects.create() en = Translations.objects.create(master=main, language_code='en') Translations.objects.create(maste...
14
646
django-cms
cms/test_utils/fixtures/templatetags.py
.py
from cms.api import create_page, create_page_content class TwoPagesFixture: def create_fixtures(self): defaults = { 'template': 'nav_playground.html', 'in_navigation': True, } with self.settings(CMS_PERMISSION=False): first = create_page('first', languag...
15
546
django-cms
cms/test_utils/util/fuzzy_int.py
.py
class FuzzyInt(int): def __new__(cls, lowest, highest): obj = super().__new__(cls, highest) obj.lowest = lowest obj.highest = highest return obj def __eq__(self, other): return other >= self.lowest and other <= self.highest def __repr__(self): return "[%d..%...
17
520
django-cms
cms/test_utils/util/static_analysis.py
.py
import os from io import StringIO from pyflakes import api from pyflakes.checker import Checker from pyflakes.reporter import Reporter def _pyflakes_report_with_nopyflakes(self, messageClass, node, *args, **kwargs): with open(self.filename) as code: if code.readlines()[node.lineno - 1].strip().endswith('...
48
1,555
django-cms
cms/test_utils/util/mock.py
.py
class AttributeObject: """ mock = AttributeObject(hello='world') mock.hello # 'world' """ def __init__(self, **kwargs): self.kwargs = kwargs for key, value in kwargs.items(): setattr(self, key, value) def __repr__(self): return '<AttributeObject: %r>' % self....
19
487
django-cms
cms/test_utils/util/context_managers.py
.py
import sys from contextlib import contextmanager from io import StringIO from shutil import rmtree as _rmtree from tempfile import _exists, mkdtemp, template from django.contrib.auth import get_user_model from django.test.utils import override_settings from django.utils.translation import activate, get_language from ...
189
5,033
django-cms
cms/test_utils/util/menu_extender.py
.py
from cms.menu_bases import CMSAttachMenu from menus.base import NavigationNode from menus.menu_pool import menu_pool class TestMenu(CMSAttachMenu): name = "test menu" def get_nodes(self, request): nodes = [] n = NavigationNode('sample root page', "/", 1) n2 = NavigationNode('sample se...
23
644
django-cms
cms/test_utils/util/grouper.py
.py
def wo_content_permission(method): """Decorator to temporarily switch of write permissions to content""" def inner(self, *args, **kwargs): self.admin.change_content = False try: return_value = method(self, *args, **kwargs) except Exception: raise finally: ...
13
410
django-cms
cms/tests/test_settings.py
.py
from classytags.utils import flatten_context from django.core.exceptions import ImproperlyConfigured from django.template.loader import render_to_string from django.test.utils import override_settings from cms import constants from cms.test_utils.testcases import CMSTestCase from cms.utils.conf import get_cms_setting ...
54
1,889
django-cms
cms/tests/test_page_user_group_admin.py
.py
from django.contrib.messages.storage.cookie import CookieStorage from django.forms.models import model_to_dict from django.test.utils import override_settings from cms.models.permissionmodels import PageUserGroup from cms.test_utils.testcases import CMSTestCase from cms.utils.urlutils import admin_reverse class Perm...
478
18,326
django-cms
cms/tests/test_api.py
.py
import sys from unittest.mock import patch from django.contrib.auth import get_user_model from django.contrib.auth.models import Permission from django.contrib.contenttypes.models import ContentType from django.contrib.sites.models import Site from django.core.exceptions import FieldError from django.db import connect...
476
22,486
django-cms
cms/tests/test_placeholder_admin.py
.py
from unittest.mock import patch from django.contrib.contenttypes.models import ContentType from django.db import connection from django.forms.models import model_to_dict from django.test.utils import CaptureQueriesContext, override_settings from cms.api import add_plugin, create_page from cms.models import CMSPlugin,...
916
52,944
django-cms
cms/tests/test_cms_config_wizards.py
.py
from unittest.mock import Mock from django.apps import apps from django.core.exceptions import ImproperlyConfigured from cms.app_registration import get_cms_config_apps, get_cms_extension_apps from cms.cms_config import CMSCoreExtensions from cms.cms_wizards import cms_page_wizard, cms_subpage_wizard from cms.test_ut...
93
3,572
django-cms
cms/tests/test_views.py
.py
import re import sys from django.conf import settings from django.contrib.auth import get_user_model from django.contrib.auth.models import Permission from django.contrib.contenttypes.models import ContentType from django.core.cache import cache from django.http import Http404, HttpResponse from django.template import...
700
30,676
django-cms
cms/tests/test_app_registration.py
.py
from importlib import import_module from unittest.mock import Mock, patch from django.apps import AppConfig, apps from django.core.exceptions import ImproperlyConfigured from django.test import override_settings from cms import app_registration from cms.apps import CMSConfig from cms.test_utils.testcases import CMSTe...
560
24,519
django-cms
cms/tests/test_placeholder_app_admin.py
.py
from unittest.mock import patch from django.forms.models import model_to_dict from cms.api import add_plugin from cms.models import CMSPlugin, Placeholder, UserSettings from cms.test_utils.project.placeholderapp.models import Example1 from cms.test_utils.testcases import CMSTestCase from cms.test_utils.util.context_m...
888
36,980
django-cms
cms/tests/test_grouper_admin.py
.py
import copy from unittest.mock import MagicMock, patch from django.conf import settings from django.contrib.admin import site from django.contrib.auth import get_permission_codename from django.contrib.sites.models import Site from django.db import connection from django.templatetags.static import static from django.t...
1,289
61,494
django-cms
cms/tests/test_toolbar.py
.py
import datetime import re from types import SimpleNamespace from unittest.mock import patch import iptools from django.conf import settings from django.contrib import admin from django.contrib.admin import site from django.contrib.auth.models import AnonymousUser, Permission from django.contrib.contenttypes.models imp...
2,975
132,389
django-cms
cms/tests/test_placeholder_operation_signals.py
.py
from cms.api import add_plugin from cms.models import Placeholder, UserSettings from cms.operations import ( ADD_PLUGIN, ADD_PLUGINS_FROM_PLACEHOLDER, CHANGE_PLUGIN, CLEAR_PLACEHOLDER, CUT_PLUGIN, DELETE_PLUGIN, MOVE_PLUGIN, PASTE_PLACEHOLDER, PASTE_PLUGIN, ) from cms.signals import ...
706
30,998
django-cms
cms/tests/test_static_analysis.py
.py
import os from unittest import TestCase from ruff.__main__ import find_ruff_bin class AboveStaticAnalysisCodeTest(TestCase): """ Name is pretty lame, but ensure it's executed before every other test """ def test_ruff(self): ruff = find_ruff_bin() self.assertEqual(os.spawnv(os.P_WAIT, ...
14
365
django-cms
cms/tests/test_templates.py
.py
import os.path from importlib.machinery import SourceFileLoader from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.template import TemplateDoesNotExist, loader from django.test.utils import override_settings from django.utils.encoding import force_str from django.utils...
143
6,047
django-cms
cms/tests/test_page.py
.py
import datetime import functools import os.path from unittest import skipIf from django.conf import settings from django.contrib.auth import get_user_model from django.contrib.sites.models import Site from django.core.cache import cache from django.core.exceptions import ValidationError from django.db import models fr...
1,105
47,642
django-cms
cms/tests/test_fixture_loading.py
.py
import codecs import tempfile try: from cStringIO import StringIO except ImportError: from io import StringIO from django.core.management import call_command from cms.models import CMSPlugin, Page, Placeholder from cms.test_utils.fixtures.navextenders import NavextendersFixture from cms.test_utils.testcases ...
47
1,779
django-cms
cms/tests/test_sitemap.py
.py
import copy from django.db.models import QuerySet from cms.api import create_page, create_page_content from cms.models import PageUrl from cms.sitemaps import CMSSitemap from cms.test_utils.testcases import CMSTestCase from cms.utils.conf import get_cms_setting protocol = "https" class SitemapTestCase(CMSTestCase)...
131
5,085
django-cms
cms/tests/test_nested_plugins.py
.py
from djangocms_text.models import Text from cms.api import add_plugin, create_page from cms.models import Page from cms.models.placeholdermodel import Placeholder from cms.models.pluginmodel import CMSPlugin from cms.tests.test_plugins import PluginsTestBaseCase from cms.utils.plugins import copy_plugins_to_placeholde...
1,234
59,740
django-cms
cms/tests/test_page_admin.py
.py
import datetime import json import re import sys from unittest import skipUnless from unittest.mock import patch from django.conf import settings from django.contrib import admin from django.contrib.sites.models import Site from django.core.cache import cache from django.db import IntegrityError, connection, transacti...
5,343
223,014
django-cms
cms/tests/test_check.py
.py
from contextlib import contextmanager from copy import deepcopy from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.test import TestCase from djangocms_text.cms_plugins import TextPlugin from cms.api import add_plugin from cms.models.placeholdermodel import Placeholder...
229
8,382
django-cms
cms/tests/test_toolbar_pool.py
.py
from collections import OrderedDict from django.core.exceptions import ImproperlyConfigured from cms import api from cms.exceptions import ToolbarAlreadyRegistered, ToolbarNotRegistered from cms.test_utils.testcases import CMSTestCase from cms.toolbar.utils import get_object_edit_url from cms.toolbar_base import CMST...
72
2,664
django-cms
cms/tests/test_migrations.py
.py
import importlib from io import StringIO from django.apps import apps from django.core.management import call_command from django.db import IntegrityError, connection, migrations, models, transaction from django.db.migrations.state import ProjectState from django.test import TestCase, TransactionTestCase, override_set...
177
7,500
django-cms
cms/tests/test_staticfiles.py
.py
import copy import json import os import re import shutil import tempfile from io import StringIO from django.conf import settings from django.core.management import call_command from django.template import Context, Template from django.test import SimpleTestCase, override_settings import cms MANIFEST_BACKEND = "dja...
119
4,601
django-cms
cms/tests/test_rendering.py
.py
from django.core.cache import cache from django.http.response import Http404 from django.test.utils import override_settings from django.urls import reverse from sekizai.context import SekizaiContext from cms import plugin_rendering from cms.api import add_plugin, create_page from cms.cache.placeholder import get_plac...
983
41,611
django-cms
cms/tests/test_menu.py
.py
import copy from django.contrib.auth.models import AnonymousUser, Group, Permission from django.contrib.sites.models import Site from django.core.cache import caches from django.db import connection from django.template import Template, TemplateSyntaxError from django.template.context import Context from django.test.u...
2,217
85,080
django-cms
cms/tests/test_startcmsproject.py
.py
import io import json import os import sys import tarfile import tempfile import urllib.error from io import StringIO from unittest import mock from django.core.management import CommandError from django.test import SimpleTestCase from cms.management.commands.startcmsproject import Command MANAGE_PY = """#!/usr/bin/...
804
34,375
django-cms
cms/tests/test_widgets.py
.py
from cms.api import create_page from cms.forms.widgets import PageSelectWidget, PageSmartLinkWidget from cms.test_utils.testcases import CMSTestCase class WidgetTestCases(CMSTestCase): def test_pageselectwidget(self): page = create_page("Test page", "nav_playground.html", "en") page2 = create_page...
25
1,173
django-cms
cms/tests/test_po.py
.py
import os import shutil import subprocess import sys from pathlib import Path from django.core.management.base import CommandError from django.core.management.commands.compilemessages import has_bom from django.test.testcases import TestCase from cms.test_utils.util.context_managers import TemporaryDirectory THIS_DI...
78
3,140
django-cms
cms/tests/test_nonroot.py
.py
from django.template import Template from django.test.utils import override_settings from cms.api import create_page from cms.models import Page from cms.test_utils.testcases import CMSTestCase from menus.base import NavigationNode @override_settings(ROOT_URLCONF='cms.test_utils.project.nonroot_urls') class NonRootC...
68
2,608
django-cms
cms/tests/test_apphook_reload_language_variants.py
.py
""" Tests for apphook URL reloading when creating language variants. This tests the fix for issue #8357 where creating new language variants for pages with apphooks causes NoReverseMatch exceptions. The fix works by ensuring that when a new PageContent (language variant) is created for a page with an apphook, the set...
227
8,570
django-cms
cms/tests/test_forms.py
.py
from html import unescape from django.contrib.auth import get_user_model from django.contrib.sites.models import Site from django.core.cache import cache from django.core.exceptions import ValidationError from django.utils.translation import override as force_language from cms.admin import forms from cms.admin.forms ...
660
26,943
django-cms
cms/tests/test_permissions.py
.py
from unittest.mock import patch from django.contrib.auth.models import Group from django.contrib.sites.models import Site from django.db import OperationalError, ProgrammingError from django.test.utils import override_settings from cms.admin.permissionadmin import GlobalPagePermissionAdmin, PagePermissionInlineAdmin ...
311
13,140
django-cms
cms/tests/test_placeholder.py
.py
import warnings from unittest.mock import patch from django.conf import settings from django.contrib.auth import get_user_model from django.contrib.sites.models import Site from django.core.exceptions import ImproperlyConfigured from django.template import Template, TemplateSyntaxError, engines from django.template.lo...
1,780
79,005
django-cms
cms/tests/test_security.py
.py
from django.conf import settings from django.contrib.auth import get_user_model from django.http import QueryDict from cms.api import add_plugin, create_page from cms.models.pluginmodel import CMSPlugin from cms.test_utils.testcases import CMSTestCase class SecurityTests(CMSTestCase): """ Test security issue...
223
10,314
django-cms
cms/tests/test_toolbar_enabled_models.py
.py
from unittest.mock import Mock, patch from django.apps import apps from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ImproperlyConfigured from django.http import Http404 from cms.api import create_page from cms.app_registration import get_cms_config_apps, get_cms_extension_...
184
7,723
django-cms
cms/tests/test_placeholder_checks.py
.py
from unittest.mock import Mock, call, patch from django.forms.models import model_to_dict from cms.api import create_page from cms.models import Placeholder, UserSettings, fields from cms.models.fields import PlaceholderRelationField from cms.test_utils.testcases import CMSTestCase class ChecksTestCase(CMSTestCase)...
317
12,274
django-cms
cms/tests/test_navextender.py
.py
from django.contrib.sites.models import Site from django.template import Template from cms.models import Page, PageContent from cms.test_utils.fixtures.navextenders import NavextendersFixture from cms.test_utils.testcases import CMSTestCase from cms.test_utils.util.menu_extender import TestMenu from menus.menu_pool im...
97
3,511
django-cms
cms/tests/test_site.py
.py
import warnings from django.contrib.sites.models import Site from django.test import RequestFactory, override_settings from cms.api import create_page from cms.models import Page from cms.test_utils.testcases import CMSTestCase from cms.utils import get_current_site from cms.utils.admin import get_site_from_request f...
161
7,016
django-cms
cms/tests/test_page_user_admin.py
.py
from unittest.mock import patch from django.contrib import admin from django.contrib.auth import get_permission_codename, get_user_model from django.contrib.messages.storage.cookie import CookieStorage from django.contrib.sites.models import Site from django.core.exceptions import PermissionDenied from django.forms.mo...
686
26,808
django-cms
cms/tests/test_i18n.py
.py
from importlib import import_module from unittest.mock import patch from django.conf import settings from django.template.context import Context from django.test.utils import override_settings from django.utils import translation from cms import api from cms.test_utils.testcases import CMSTestCase from cms.utils impo...
676
24,742
django-cms
cms/tests/test_urlutils.py
.py
from cms.test_utils.testcases import CMSTestCase from cms.utils import urlutils class UrlutilsTestCase(CMSTestCase): def test_levelize_path(self): path = '/application/item/new' output = ['/application/item/new', '/application/item', '/application'] self.assertEqual(urlutils.levelize_path(...
30
1,349
django-cms
cms/tests/test_menu_utils.py
.py
from urllib.parse import urlencode from django.http import HttpResponse from cms.api import create_page, create_page_content from cms.test_utils.testcases import CMSTestCase from cms.test_utils.util.mock import AttributeObject from cms.toolbar.toolbar import CMSToolbar from cms.utils.i18n import get_language_list fro...
180
7,428
django-cms
cms/tests/test_templatetags.py
.py
import os from copy import deepcopy from unittest.mock import patch from django.conf import settings from django.contrib.auth.models import AnonymousUser from django.contrib.sessions.backends.base import SessionBase from django.contrib.sites.models import Site from django.core import mail from django.core.exceptions i...
914
42,267
django-cms
cms/tests/settings.py
.py
"""Django settings module for running the django CMS test suite with pytest. This mirrors the configuration that ``manage.py`` builds dynamically and passes to ``settings.configure()``. It is exposed as an importable settings module so that ``pytest`` (via ``pytest-django``) and ``django-admin`` can pick it up through...
328
10,309
django-cms
cms/tests/test_admin.py
.py
import json from django.conf import settings from django.contrib import admin from django.contrib.admin.sites import site from django.contrib.admin.utils import flatten_fieldsets from django.contrib.auth import get_user_model from django.contrib.auth.models import Permission from django.contrib.sites.models import Sit...
1,428
60,360
django-cms
cms/tests/test_multilingual.py
.py
import copy from django.contrib.sites.models import Site from django.test.utils import override_settings from django.urls import reverse from cms.api import add_plugin, create_page, create_page_content from cms.exceptions import LanguageError from cms.forms.utils import update_site_and_page_choices from cms.models im...
319
13,845
django-cms
cms/tests/test_no_i18n.py
.py
from unittest.mock import patch from django.contrib.auth import get_user_model from django.template import Template from django.test.utils import override_settings from django.urls import clear_url_caches from django.utils.translation import trans_null from cms.api import create_page from cms.constants import TEMPLAT...
157
6,834
django-cms
cms/tests/test_extensions.py
.py
from copy import deepcopy from django.contrib.auth import get_user_model from django.contrib.auth.models import Permission from django.contrib.sites.models import Site from cms.api import create_page, create_page_content from cms.extensions import PageContentExtension, PageExtension, extension_pool from cms.extension...
496
22,640
django-cms
cms/tests/test_signals.py
.py
import warnings from django.conf import settings from django.test.utils import override_settings from cms.api import create_page from cms.models import Page, UrlconfRevision from cms.signals import move_page, urls_need_reloading from cms.test_utils.project.sampleapp.cms_apps import SampleApp from cms.test_utils.testc...
112
4,929
django-cms
cms/tests/test_mptree_backend.py
.py
""" Guardrail + functional tests for the swappable tree backend. * ``TreeFieldParityTests`` proves the swap is *migration-invisible*: Django builds migrations purely from field deconstruction, so if ``MaterializedPathMixin`` deconstructs its tree fields identically to treebeard's ``MP_Node``, substituting one fo...
1,056
41,445
django-cms
cms/tests/test_plugin_renderers.py
.py
from collections import deque from django.template import Context from django.test.utils import override_settings from cms.api import add_plugin, create_page from cms.models import CMSPlugin, Placeholder from cms.plugin_rendering import ( ContentRenderer, LegacyRenderer, StructureRenderer, ) from cms.test...
598
26,518
django-cms
cms/tests/test_management.py
.py
import sys from io import StringIO from django.conf import settings from django.contrib.auth import get_user_model from django.contrib.contenttypes.models import ContentType from django.contrib.sites.models import Site from django.core import management from django.core.management import CommandError from django.db im...
890
37,198
django-cms
cms/tests/test_plugins.py
.py
import datetime import pickle import warnings from contextlib import contextmanager from unittest import mock, skipIf from django import http from django.conf import settings from django.contrib import admin from django.contrib.admin.widgets import FilteredSelectMultiple, RelatedFieldWidgetWrapper from django.core.exc...
2,173
98,418
django-cms
cms/tests/test_wizards.py
.py
from unittest.mock import Mock, patch from django import forms from django.apps import apps from django.apps.registry import Apps from django.contrib.sites.models import Site from django.core.exceptions import ImproperlyConfigured from django.forms.models import ModelForm from django.template import TemplateSyntaxErro...
754
28,344
django-cms
cms/tests/test_menu_page_viewperm_staff.py
.py
from django.contrib.auth import get_user_model from django.test.utils import override_settings from cms.tests.test_menu_page_viewperm import ViewPermissionTests __all__ = [ 'ViewPermissionComplexMenuStaffNodeTests', ] @override_settings( CMS_PERMISSION=True, CMS_PUBLIC_FOR='staff', ) class ViewPermissio...
446
17,944
django-cms
cms/tests/test_mail.py
.py
from django.contrib.auth import get_user_model from django.core import mail from cms.api import create_page_user from cms.test_utils.testcases import CMSTestCase from cms.utils.mail import mail_page_user_change class MailTestCase(CMSTestCase): def setUp(self): mail.outbox = [] # reset outbox def te...
18
602
django-cms
cms/tests/test_menu_page_viewperm.py
.py
from django.contrib.auth import get_user_model from django.contrib.auth.models import AnonymousUser, Group from django.contrib.sites.models import Site from django.test.utils import override_settings from cms.api import create_page from cms.cms_menus import get_visible_page_contents from cms.models import ( ACCESS...
650
23,888
django-cms
cms/tests/test_helpers.py
.py
from cms.models import Page, PageContent from cms.test_utils.project.sampleapp.models import ( Category, Picture, SomeEditableModel, ) from cms.test_utils.testcases import CMSTestCase from cms.utils.helpers import is_editable_model class HelperTests(CMSTestCase): def test_is_editable_model(self): ...
35
1,211
django-cms
cms/tests/test_apphooks.py
.py
import sys import types import uuid from django.apps import apps from django.contrib.auth import get_user_model from django.contrib.auth.models import Permission from django.contrib.contenttypes.models import ContentType from django.contrib.sites.models import Site from django.core import checks from django.core.cache...
1,499
63,922
django-cms
cms/tests/test_log_entries.py
.py
from django.contrib.admin.models import ADDITION, CHANGE, DELETION, LogEntry from django.forms.models import model_to_dict from django.utils.translation import gettext_lazy as _ from cms.api import add_plugin, create_page, create_page_content from cms.forms.wizards import CreateCMSPageForm from cms.models import Page,...
582
26,054
django-cms
cms/tests/test_cache.py
.py
import time from django.conf import settings from django.template import Context from sekizai.context import SekizaiContext from cms.api import add_plugin, create_page, create_page_content from cms.cache import invalidate_cms_page_cache from cms.cache.page import ( _page_cache_key, _page_url_key, _page_va...
1,115
47,015
django-cms
cms/tests/test_permmod.py
.py
from unittest.mock import patch from django.contrib.admin.sites import site from django.contrib.auth import get_user_model from django.contrib.auth.models import AnonymousUser, Group, Permission from django.contrib.sites.models import Site from django.db.models import Q from django.test.client import RequestFactory fr...
676
27,912
django-cms
cms/utils/apphook_reload.py
.py
import logging import sys import uuid # Py2 and Py3 compatible reload from importlib import reload from threading import local from django.conf import settings from django.urls import clear_url_caches logger = logging.getLogger("cms") _urlconf_revision = {} _urlconf_revision_threadlocal = local() use_threadlocal =...
106
2,978
django-cms
cms/utils/admin.py
.py
from django.contrib.sites.models import Site from django.forms import IntegerField, ValidationError from django.http import JsonResponse from django.utils.encoding import smart_str from cms.utils import get_current_site NOT_FOUND_RESPONSE = "NotFound" def jsonify_request(response): """ Turn any response in a 20...
30
996
django-cms
cms/utils/placeholder.py
.py
import operator import os import warnings from collections import OrderedDict, defaultdict from functools import cache from typing import TYPE_CHECKING from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.db import connection, models from django.template import ( Con...
443
17,269
django-cms
cms/utils/mail.py
.py
from django.contrib.sites.models import Site from django.core.mail import EmailMultiAlternatives from django.template.loader import render_to_string from django.utils.translation import gettext_lazy as _ from cms.utils.urlutils import admin_reverse, urljoin def send_mail(subject, txt_template, to, context=None, html...
45
1,513
django-cms
cms/utils/setup.py
.py
from django.core.exceptions import ImproperlyConfigured from django.template import engines from django.template.backends.django import DjangoTemplates from cms.app_registration import ( autodiscover_cms_configs, backwards_compatibility_config, configure_cms_apps, get_cms_extension_apps, ready_cms_...
74
2,350