File: test_ddf_checkings.py

package info (click to toggle)
python-django-dynamic-fixture 4.0.1-1~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 616 kB
  • sloc: python: 3,909; makefile: 237; sh: 6
file content (41 lines) | stat: -rw-r--r-- 1,346 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41

from django.test import TestCase

from django_dynamic_fixture.ddf import DDFLibrary
from django_dynamic_fixture import ddf_check_models, teach


class DDFTestCase(TestCase):
    def setUp(self):
        DDFLibrary.get_instance().clear()


class TestCheckCompatibility(DDFTestCase):
    def test_default(self):
        succeeded, errors = ddf_check_models()

        compatible_models = [
            'django_dynamic_fixture.EmptyModel',
            'django_dynamic_fixture.ModelWithNumbers',
        ]
        for model in compatible_models:
            assert model in succeeded.keys(), model

        incompatible_models = [
            'django_dynamic_fixture.ModelWithUnsupportedField',
        ]
        for model in incompatible_models:
            assert model in errors.keys(), model
        # TODO: Consider the RelatedObjectDoesNotExist errors
        # https://stackoverflow.com/questions/26270042/how-do-you-catch-this-exception

    def test_teaching_ddf(self):
        teach('django_dynamic_fixture.ModelWithUnsupportedField', z='z')
        succeeded, errors = ddf_check_models()

        compatible_models = [
            'django_dynamic_fixture.ModelWithUnsupportedField',
        ]
        for model in compatible_models:
            assert model in succeeded.keys(), model
            assert model not in errors.keys(), model