Exemplo n.º 1
0
 def test_str_validation_choices_test(self):
     expected = ['apple', 'banana', 'citrus']
     for item in expected:
         result = str_validation(val=item, choices=expected)
         self.assertEqual(item, result)
Exemplo n.º 2
0
 def test_str_validation_choices_wrong_item_test(self):
     choices = ['apple', 'banana', 'citrus']
     wrong_choices = ['star', 'moon']
     for item in wrong_choices:
         with self.assertRaises(Invalid):
             _ = str_validation(val=item, choices=choices)
Exemplo n.º 3
0
 def test_str_validation_failed_regex_test(self):
     """Match only two words with regex"""
     regex = r'^(\w+ )(\w+)$'
     expected = 'apple tree barks what is '
     with self.assertRaises(Invalid):
         _ = str_validation(key=None, val=expected, regex=regex)
Exemplo n.º 4
0
 def test_str_validation_reqex_test(self):
     """Match only two words with regex"""
     regex = r'^(\w+ )(\w+)$'
     expected = 'apple tree'
     result = str_validation(val=expected, regex=regex)
     self.assertEqual(expected, result)
Exemplo n.º 5
0
 def test_str_validation_max_length_failed(self):
     expected = '12345'
     with self.assertRaises(Invalid):
         _ = str_validation(val=expected, max_length=4)
Exemplo n.º 6
0
 def test_validation_max_length(self):
     expected = '1234'
     result = str_validation(val=expected, max_length=4)
     self.assertEqual(expected, result)
Exemplo n.º 7
0
 def test_str_validation_untouched_test(self):
     expected = 'banana'
     result = str_validation(val=expected)
     self.assertEqual(expected, result)