| 1 |
from django.test import TestCase |
| 2 |
|
| 3 |
from polymorphic.contrib.guardian import get_polymorphic_base_content_type |
| 4 |
from polymorphic.tests.models import Model2D, PlainC |
| 5 |
|
| 6 |
|
| 7 |
class ContribTests(TestCase): |
| 8 |
""" |
| 9 |
The test suite |
| 10 |
""" |
| 11 |
|
| 12 |
def test_contrib_guardian(self): |
| 13 |
# Regular Django inheritance should return the child model content type. |
| 14 |
obj = PlainC() |
| 15 |
ctype = get_polymorphic_base_content_type(obj) |
| 16 |
assert ctype.name == "plain c" |
| 17 |
|
| 18 |
ctype = get_polymorphic_base_content_type(PlainC) |
| 19 |
assert ctype.name == "plain c" |
| 20 |
|
| 21 |
# Polymorphic inheritance should return the parent model content type. |
| 22 |
obj = Model2D() |
| 23 |
ctype = get_polymorphic_base_content_type(obj) |
| 24 |
assert ctype.name == "model2a" |
| 25 |
|
| 26 |
ctype = get_polymorphic_base_content_type(Model2D) |
| 27 |
assert ctype.name == "model2a" |