File: test_form_meta.py

package info (click to toggle)
wtforms-alchemy 0.19.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 492 kB
  • sloc: python: 3,955; makefile: 119; sh: 11
file content (40 lines) | stat: -rw-r--r-- 1,147 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
import sqlalchemy as sa

from tests import ModelFormTestCase


class TestModelFormMetaWithInheritance(ModelFormTestCase):
    def test_skip_unknown_types(self, model_form_all):
        self.init(type_=sa.Integer)

        class ModelTestForm(model_form_all):
            class Meta:
                skip_unknown_types = True

        class ModelTestForm2(ModelTestForm):
            class Meta:
                model = self.ModelTest

        self.form_class = ModelTestForm2
        assert self.form_class.Meta.skip_unknown_types is True

    def test_inheritance_attributes(self, model_form_custom):
        self.init(type_=sa.Integer)

        class ModelTestForm(model_form_custom):
            class Meta:
                model = self.ModelTest

        assert ModelTestForm.test_attr == "SomeVal"


class TestUnboundFieldsInitialization(ModelFormTestCase):
    def test_skip_unknown_types(self, model_form_all):
        self.init(type_=sa.Integer)

        class ModelTestForm(model_form_all):
            class Meta:
                model = self.ModelTest
                skip_unknown_types = True

        assert ModelTestForm.test_column