File: test_ddf_custom_models.py

package info (click to toggle)
python-django-dynamic-fixture 4.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 616 kB
  • sloc: python: 3,909; makefile: 237; sh: 6
file content (24 lines) | stat: -rw-r--r-- 756 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
from django.test import TestCase
import pytest

from django_dynamic_fixture.models_test import *
from django_dynamic_fixture.ddf import *
from django_dynamic_fixture import G

try:
    from polymorphic.models import PolymorphicModel

    class PolymorphicModelTest(TestCase):
        def test_create_polymorphic_model_and_retrieve(self):
            p = G(ModelPolymorphic)
            assert list(ModelPolymorphic.objects.all()) == [p]

        def test_create_polymorphic_model_2_and_retrieve(self):
            p = G(ModelPolymorphic2)
            assert list(ModelPolymorphic2.objects.all()) == [p]

        def test_cannot_save(self):
            with self.assertRaises(BadDataError):
                G(ModelPolymorphic3)
except ImportError:
    pass