Exemplo n.º 1
0
 def test_validate_2D_array_of_strings(self):
     sample_strs = """'guest1','guest2','another'\n
     'right','left', 'middle' """
     sample_inv_strs = """ 'guest1','guest2','another'\n
     'right','left', '' """
     self.assertTrue(strict_validate(sample_strs, 'string'))
     self.assertFalse(strict_validate(sample_inv_strs, 'string'))
Exemplo n.º 2
0
 def test_validate_1D_array_of_ints(self):
     test_str_ints = '1,2,3,4,5,6'
     test_inv_ints = '1,2,,3,45'
     test_floats = '1.0,2,3,4'
     self.assertTrue(strict_validate(test_str_ints, 'integer'))
     self.assertFalse(strict_validate(test_inv_ints, 'integer'))
     self.assertFalse(strict_validate(test_floats, 'integer'))
Exemplo n.º 3
0
 def test_validate_1D_array_of_floats(self):
     test_str_floats = '1.0,2,3,4,5'
     test_inv_floats = '1.0,,5.0,6.0'
     test_bad_floats = '1.0,er4,5.0,6.0'
     self.assertTrue(strict_validate(test_str_floats,'float'))
     self.assertFalse(strict_validate(test_inv_floats,'float'))
     self.assertFalse(strict_validate(test_bad_floats,'float'))
Exemplo n.º 4
0
 def test_validate_2D_array_of_strings(self):
     sample_strs = """'guest1','guest2','another'\n
     'right','left', 'middle' """
     sample_inv_strs = """ 'guest1','guest2','another'\n
     'right','left', '' """
     self.assertTrue(strict_validate(sample_strs, 'string'))
     self.assertFalse(strict_validate(sample_inv_strs, 'string'))
Exemplo n.º 5
0
 def test_validate_1D_array_of_floats(self):
     test_str_floats = '1.0,2,3,4,5'
     test_inv_floats = '1.0,,5.0,6.0'
     test_bad_floats = '1.0,er4,5.0,6.0'
     self.assertTrue(strict_validate(test_str_floats, 'float'))
     self.assertFalse(strict_validate(test_inv_floats, 'float'))
     self.assertFalse(strict_validate(test_bad_floats, 'float'))
Exemplo n.º 6
0
 def test_validate_1D_array_of_ints(self):
     test_str_ints = '1,2,3,4,5,6'
     test_inv_ints = '1,2,,3,45'
     test_floats = '1.0,2,3,4'
     self.assertTrue(strict_validate(test_str_ints, 'integer'))
     self.assertFalse(strict_validate(test_inv_ints, 'integer'))
     self.assertFalse(strict_validate(test_floats, 'integer'))
Exemplo n.º 7
0
 def test_validate_2D_array_of_floats(self):
     sample_2d_floats = '''1.0, 2.0, 3.0 \n
     1.23,5.4,3.3
     ''' 
     sample_2d_invalid = '''1.0,2.0\n
     ,2.3
     '''
     tiny_sample_floats = '''1.,2.\n
     3.,4.'''
     self.assertTrue(strict_validate(sample_2d_floats, 'float'))   
     self.assertFalse(strict_validate(sample_2d_invalid, 'float'))
     self.assertTrue(strict_validate(tiny_sample_floats, 'float'))
Exemplo n.º 8
0
 def test_validate_2D_array_of_floats(self):
     sample_2d_floats = '''1.0, 2.0, 3.0 \n
     1.23,5.4,3.3
     '''
     sample_2d_invalid = '''1.0,2.0\n
     ,2.3
     '''
     tiny_sample_floats = '''1.,2.\n
     3.,4.'''
     self.assertTrue(strict_validate(sample_2d_floats, 'float'))
     self.assertFalse(strict_validate(sample_2d_invalid, 'float'))
     self.assertTrue(strict_validate(tiny_sample_floats, 'float'))
Exemplo n.º 9
0
 def test_validate_2D_array_of_ints(self):
     sample_2d_ints = ''' 1,2,3,4\n
     2,3,4,5
     1,2,3,4'''
     sample_2d_invalid = '''1,2,3,4\n
     1,2,3
     '''
     sample_2d_with_empty = '''1,2,,3\n
     1,2,3'''
     sample_2d_some_floats = '''1.0,2,3\n
     1,2,34
     '''
     self.assertTrue(strict_validate(sample_2d_ints, 'integer')) 
     self.assertFalse(strict_validate(sample_2d_invalid, 'integer'))
     self.assertFalse(strict_validate(sample_2d_with_empty, 'integer'))
     self.assertFalse(strict_validate(sample_2d_some_floats, 'integer'))
Exemplo n.º 10
0
 def test_validate_2D_array_of_ints(self):
     sample_2d_ints = ''' 1,2,3,4\n
     2,3,4,5
     1,2,3,4'''
     sample_2d_invalid = '''1,2,3,4\n
     1,2,3
     '''
     sample_2d_with_empty = '''1,2,,3\n
     1,2,3'''
     sample_2d_some_floats = '''1.0,2,3\n
     1,2,34
     '''
     self.assertTrue(strict_validate(sample_2d_ints, 'integer'))
     self.assertFalse(strict_validate(sample_2d_invalid, 'integer'))
     self.assertFalse(strict_validate(sample_2d_with_empty, 'integer'))
     self.assertFalse(strict_validate(sample_2d_some_floats, 'integer'))
Exemplo n.º 11
0
 def test_validate_single_value(self):
     test_str_int = '3'
     test_str_float = '3.0' 
     test_inv_float = '3.Osjk.9'
     test_inv_int = 'O'
     test_tiny_float = '1.'
     self.assertTrue(strict_validate(test_str_float,'float'))
     self.assertFalse(strict_validate(test_inv_float,'float'))
     self.assertFalse(strict_validate(test_str_float,'integer'))
     self.assertTrue(strict_validate(test_str_int,'integer'))
     self.assertFalse(strict_validate(test_inv_int,'integer'))
     self.assertTrue(strict_validate(test_tiny_float,'float'))
Exemplo n.º 12
0
 def test_validate_single_value(self):
     test_str_int = '3'
     test_str_float = '3.0'
     test_inv_float = '3.Osjk.9'
     test_inv_int = 'O'
     test_tiny_float = '1.'
     self.assertTrue(strict_validate(test_str_float, 'float'))
     self.assertFalse(strict_validate(test_inv_float, 'float'))
     self.assertFalse(strict_validate(test_str_float, 'integer'))
     self.assertTrue(strict_validate(test_str_int, 'integer'))
     self.assertFalse(strict_validate(test_inv_int, 'integer'))
     self.assertTrue(strict_validate(test_tiny_float, 'float'))
Exemplo n.º 13
0
 def test_validate_1D_array_of_strings(self):
     sample_array = "'one', 'two', 'three'"
     sample_inv_array = "'one', 'two', ''"
     self.assertTrue(strict_validate(sample_array, 'string'))
     self.assertFalse(strict_validate(sample_inv_array, 'string'))
Exemplo n.º 14
0
 def test_validate_string(self):
     sample_str = '1234asdf'
     empty_str = ''
     self.assertTrue(strict_validate(sample_str, 'string'))
     self.assertFalse(strict_validate(sample_str, 'string'))
Exemplo n.º 15
0
 def test_validate_1D_array_of_strings(self):
     sample_array = "'one', 'two', 'three'"
     sample_inv_array = "'one', 'two', ''"
     self.assertTrue(strict_validate(sample_array, 'string'))
     self.assertFalse(strict_validate(sample_inv_array, 'string'))
Exemplo n.º 16
0
 def test_validate_string(self):
     sample_str = '1234asdf'
     empty_str = ''
     self.assertTrue(strict_validate(sample_str, 'string'))
     self.assertFalse(strict_validate(sample_str, 'string'))