File: test_contrib.py

package info (click to toggle)
django-polymorphic 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 892 kB
  • sloc: python: 6,784; javascript: 263; makefile: 137
file content (27 lines) | stat: -rw-r--r-- 860 bytes parent folder | download | duplicates (2)
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
from django.test import TestCase

from polymorphic.contrib.guardian import get_polymorphic_base_content_type
from polymorphic.tests.models import Model2D, PlainC


class ContribTests(TestCase):
    """
    The test suite
    """

    def test_contrib_guardian(self):
        # Regular Django inheritance should return the child model content type.
        obj = PlainC()
        ctype = get_polymorphic_base_content_type(obj)
        assert ctype.name == "plain c"

        ctype = get_polymorphic_base_content_type(PlainC)
        assert ctype.name == "plain c"

        # Polymorphic inheritance should return the parent model content type.
        obj = Model2D()
        ctype = get_polymorphic_base_content_type(obj)
        assert ctype.name == "model2a"

        ctype = get_polymorphic_base_content_type(Model2D)
        assert ctype.name == "model2a"