Ejemplo n.º 1
0
    def test_default(self, value):
        """Pass in a field that has no default value or choices.

        Assert the default argument to ``_get_value`` is returned.

        """
        field = orm.StringField()
        self.assertEqual(orm._get_value(field, lambda: value), value)
        self.assertEqual(orm._get_value(field, value), value)
Ejemplo n.º 2
0
    def test_field_default_and_choices(self):
        """Pass in a field that has a default and choices.

        Assert the default value is returned.

        """
        field = orm.StringField(choices=('a', 'b', 'c'), default='d')
        self.assertEqual(orm._get_value(field, None), 'd')
Ejemplo n.º 3
0
    def test_field_default(self, value):
        """Pass in a field that has a default value of ``value``.

        Assert ``value`` is returned.

        """
        field = orm.StringField(default=value)
        self.assertEqual(orm._get_value(field, None), value)
Ejemplo n.º 4
0
    def test_field_choices(self):
        """Pass in a field that has a set of choices.

        Assert a value from the choices is returned.

        """
        field = orm.StringField(choices=('a', 'b', 'c'))
        self.assertIn(orm._get_value(field, None), ('a', 'b', 'c'))