File: test_compat.py

package info (click to toggle)
python-django-extensions 4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,820 kB
  • sloc: python: 18,601; javascript: 7,354; makefile: 108; xml: 17
file content (30 lines) | stat: -rw-r--r-- 999 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -*- coding: utf-8 -*-
from django.test import TestCase
from django.test.utils import override_settings

from django_extensions.compat import get_template_setting


class CompatTests(TestCase):
    @override_settings(TEMPLATES=None)
    def test_should_return_None_by_default_if_TEMPLATES_setting_is_none(self):
        self.assertIsNone(get_template_setting("template_key"))

    @override_settings(TEMPLATES=None)
    def test_should_return_default_if_TEMPLATES_setting_is_none(self):
        self.assertEqual(get_template_setting("template_key", "test"), "test")

    @override_settings(
        TEMPLATES=[
            {
                "BACKEND": "django.template.backends.django.DjangoTemplates",
                "DIRS": ["templates"],
                "APP_DIRS": True,
            }
        ]
    )
    def test_should_return_value_for_key(self):
        self.assertEqual(
            get_template_setting("BACKEND"),
            "django.template.backends.django.DjangoTemplates",
        )