Ejemplo n.º 1
0
    def test_handles_multivaluedict_properly(self):
        single, multi, empty, blank, missing = mock.get_multivalue_examples(
            'name', ['Croissant', 'Marzipan'])
        for input_data in [single, multi]:
            field = NameField(input_data)
            self.assertTrue(field.is_valid())
            self.assertEqual(field.get_current_value(), 'Marzipan')

        for input_data in [empty, blank, missing]:
            field = NameField(input_data)
            self.assertFalse(field.is_valid())
            self.assertEqual(field.get_current_value(), '')

        for input_data in [empty, blank, missing]:
            field = NameField(input_data, required=False)
            self.assertTrue(field.is_valid())
            self.assertEqual(field.get_current_value(), '')
Ejemplo n.º 2
0
    def test_handles_multivaluedict_properly(self):
        single, multi, empty, blank, missing = mock.get_multivalue_examples(
            'name', ['Croissant', 'Marzipan'])
        for input_data in [single, multi]:
            field = NameField(input_data)
            self.assertTrue(field.is_valid())
            self.assertEqual(field.get_current_value(), 'Marzipan')

        for input_data in [empty, blank, missing]:
            field = NameField(input_data)
            self.assertFalse(field.is_valid())
            self.assertEqual(field.get_current_value(), '')

        for input_data in [empty, blank, missing]:
            field = NameField(input_data, required=False)
            self.assertTrue(field.is_valid())
            self.assertEqual(field.get_current_value(), '')
Ejemplo n.º 3
0
    def test_handles_multivaluedict_properly(self):
        single, multi, empty, blank, missing = mock.get_multivalue_examples(
            'fruit', ['oranges', 'apples'])

        for input_data in [single, multi]:
            field = SingleFruit(input_data)
            self.assertTrue(field.is_valid())
            self.assertEqual(field.get_current_value(), 'apples')

        for input_data in [empty, blank, missing]:
            field = SingleFruit(input_data)
            self.assertFalse(field.is_valid())
            self.assertEqual(field.get_current_value(), '')

        for input_data in [empty, blank, missing]:
            field = SingleFruit(input_data, required=False)
            self.assertTrue(field.is_valid())
            self.assertEqual(field.get_current_value(), '')
Ejemplo n.º 4
0
    def test_handles_multivaluedict_properly(self):
        single, multi, empty, blank, missing = mock.get_multivalue_examples(
            'fruit', ['oranges', 'apples'])

        for input_data in [single, multi]:
            field = SingleFruit(input_data)
            self.assertTrue(field.is_valid())
            self.assertEqual(field.get_current_value(), 'apples')

        for input_data in [empty, blank, missing]:
            field = SingleFruit(input_data)
            self.assertFalse(field.is_valid())
            self.assertEqual(field.get_current_value(), '')

        for input_data in [empty, blank, missing]:
            field = SingleFruit(input_data, required=False)
            self.assertTrue(field.is_valid())
            self.assertEqual(field.get_current_value(), '')
Ejemplo n.º 5
0
    def test_handles_multivaluedict_properly(self):
        class IsThisAnArgument(field_types.YesNoField):
            context_key = 'is_an_argument'

        single, multi, empty, blank, missing = mock.get_multivalue_examples(
            'is_an_argument', ['no', 'yes'])

        for input_data in [single, multi]:
            field = IsThisAnArgument(input_data)
            self.assertTrue(field.is_valid())
            self.assertEqual(field.get_current_value(), 'yes')

        for input_data in [empty, blank, missing]:
            field = IsThisAnArgument(input_data)
            self.assertFalse(field.is_valid())
            self.assertEqual(field.get_current_value(), '')

        for input_data in [empty, blank, missing]:
            field = IsThisAnArgument(input_data, required=False)
            self.assertTrue(field.is_valid())
            self.assertEqual(field.get_current_value(), '')
Ejemplo n.º 6
0
    def test_handles_multivaluedict_properly(self):

        class IsThisAnArgument(field_types.YesNoField):
            context_key = 'is_an_argument'

        single, multi, empty, blank, missing = mock.get_multivalue_examples(
            'is_an_argument', ['no', 'yes'])

        for input_data in [single, multi]:
            field = IsThisAnArgument(input_data)
            self.assertTrue(field.is_valid())
            self.assertEqual(field.get_current_value(), 'yes')

        for input_data in [empty, blank, missing]:
            field = IsThisAnArgument(input_data)
            self.assertFalse(field.is_valid())
            self.assertEqual(field.get_current_value(), '')

        for input_data in [empty, blank, missing]:
            field = IsThisAnArgument(input_data, required=False)
            self.assertTrue(field.is_valid())
            self.assertEqual(field.get_current_value(), '')