Beispiel #1
0
 def test_not_required(self):
     """
     Tests that a validation error
     is raised only when appropriate.
     """
     l = ListField('field', required=False)
     obj = l.translate(None, validate=True)
     self.assertListEqual(obj, [])
Beispiel #2
0
 def test_not_required(self):
     """
     Tests that a validation error
     is raised only when appropriate.
     """
     l = ListField('field', required=False)
     obj = l.translate(None, validate=True)
     self.assertListEqual(obj, [])
Beispiel #3
0
 def test_validate_items(self):
     """
     Tests validating the items in the list
     """
     items = [10, 15]
     l = ListField('field', indv_field=IntegerField('int', minimum=5))
     resp_items = l.translate(items, validate=True)
     self.assertEqual(items, resp_items)
     items = [15, 0]
     self.assertRaises(ValidationException, l.translate, items, validate=True)
Beispiel #4
0
 def test_translate_items(self):
     """
     Tests validating the items.
     """
     items = [datetime.datetime.now(), 'gonna break']
     l = ListField('field', indv_field=DateTimeField('datetime'))
     self.assertRaises(TranslationException, l.translate, items)
     items = [datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S.%fZ')]
     resp_items = l.translate(items)
     self.assertEqual(len(resp_items), 1)
     self.assertIsInstance(resp_items[0], datetime.datetime)
Beispiel #5
0
 def test_translate_items(self):
     """
     Tests validating the items.
     """
     items = [datetime.datetime.now(), 'gonna break']
     l = ListField('field', indv_field=DateTimeField('datetime'))
     self.assertRaises(TranslationException, l.translate, items)
     items = [datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S.%fZ')]
     resp_items = l.translate(items)
     self.assertEqual(len(resp_items), 1)
     self.assertIsInstance(resp_items[0], datetime.datetime)
Beispiel #6
0
 def test_validate_items(self):
     """
     Tests validating the items in the list
     """
     items = [10, 15]
     l = ListField('field', indv_field=IntegerField('int', minimum=5))
     resp_items = l.translate(items, validate=True)
     self.assertEqual(items, resp_items)
     items = [15, 0]
     self.assertRaises(ValidationException,
                       l.translate,
                       items,
                       validate=True)