Пример #1
0
    def test_no_data(self):
        form = self.get_form()

        assert not form.validate(), "Form was valid"

        ichoices = list(form.author.iter_choices())
        self.assertEqual(len(ichoices), len(self.authors))
        for author, (key, label, selected) in zip(self.authors, ichoices):
            self.assertEqual(key, KeyPropertyField._key_value(author.key))
Пример #2
0
    def test_no_data(self):
        form = self.get_form()

        assert not form.validate(), "Form was valid"

        ichoices = list(form.author.iter_choices())
        self.assertEqual(len(ichoices), len(self.authors))
        for author, (key, label, selected) in zip(self.authors, ichoices):
            self.assertEqual(key, KeyPropertyField._key_value(author.key))
Пример #3
0
    def test_no_data(self, client):
        with client.context():
            self.setUp()
            form = self.get_form()
            assert not form.validate(), "Form was valid"

            ichoices = list(form.author.iter_choices())

            assert len(ichoices) == len(self.authors)
            for author, (key, label, selected) in zip(self.authors, ichoices):
                assert key == KeyPropertyField._key_value(author.key)
Пример #4
0
    def test_valid_form_data(self):
        # Valid data
        data = DummyPostData(
            author=KeyPropertyField._key_value(self.first_author_key))

        form = self.get_form(data)

        assert form.validate(), "Form validation failed. %r" % form.errors

        # Check that our first author was selected
        ichoices = list(form.author.iter_choices())
        self.assertEqual(len(ichoices), len(self.authors))
        self.assertEqual(list(x[2] for x in ichoices), [True, False, False])

        self.assertEqual(form.author.data, self.first_author_key)
Пример #5
0
    def test_valid_form_data(self):
        # Valid data
        data = DummyPostData(
            author=KeyPropertyField._key_value(self.first_author_key))

        form = self.get_form(data)

        assert form.validate(), "Form validation failed. %r" % form.errors

        # Check that our first author was selected
        ichoices = list(form.author.iter_choices())
        self.assertEqual(len(ichoices), len(self.authors))
        self.assertEqual(list(x[2] for x in ichoices), [True, False, False])

        self.assertEqual(form.author.data, self.first_author_key)
Пример #6
0
    def test_valid_form_data(self, client):
        with client.context():
            self.setUp()
            # Valid data
            data = DummyPostData(
                author=KeyPropertyField._key_value(self.first_author_key))

            form = self.get_form(data)
            assert form.validate(), "Form validation failed. %r" % form.errors

            # Check that our first author was selected
            ichoices = list(form.author.iter_choices())

            assert len(ichoices) == len(self.authors)
            assert [x[2] for x in ichoices] == [True, False, False]

            assert form.author.data == self.first_author_key
Пример #7
0
 class F(Form):
     author = KeyPropertyField(reference_class=Author)
Пример #8
0
 class F(Form):
     empty = KeyPropertyField(reference_class=AncestorModel)
Пример #9
0
class RastileimauksetForm(RastileimauksetBaseForm):
    aika = StringField('aika', validators=[InputRequired(), validateAika])
    rasti = KeyPropertyField(reference_class=Rasti,
                             get_label=rasti_label)  #, validate_koodi)