File: test_registry.py

package info (click to toggle)
django-ajax-selects 1.7.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 356 kB
  • sloc: python: 924; javascript: 191; makefile: 4
file content (35 lines) | stat: -rw-r--r-- 1,381 bytes parent folder | download | duplicates (3)
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
31
32
33
34
35

from django.test import TestCase
import ajax_select


class TestRegistry(TestCase):

    def test_lookup_py_is_autoloaded(self):
        """Django >= 1.7 autoloads tests/lookups.py"""
        is_registered = ajax_select.registry.is_registered('person')
        self.assertTrue(is_registered)

    def test_back_compatible_loads_by_settings(self):
        """a module and class specified in settings"""
        self.assertTrue(ajax_select.registry.is_registered('book'))

    def test_autoconstruct_from_spec(self):
        """a dict in settings specifying model and lookup fields"""
        self.assertTrue(ajax_select.registry.is_registered('author'))

    def test_unsetting_a_channel(self):
        """settings can unset a channel that was specified in a lookups.py"""
        # self.assertFalse(ajax_select.registry.is_registered('user'))
        self.assertFalse(
            ajax_select.registry.is_registered('was-never-a-channel'))

    # def test_reimporting_lookup(self):
    #     """
    #     Importing a lookup should not re-register it after app launch is completed.
    #     """
    #     # importing this file will cause the @register to be called
    #     from tests import lookups  # noqa
    #     # should not have over-ridden what is in settings
    #     # registry is already frozen
    #     self.assertFalse(ajax_select.registry.is_registered('user'))