コード例 #1
0
 def test_order_invalid(self):
     for x in ['dsc', 'ascending']:
         with self.assertRaises(ValueError):
             validate_parameter('order', x)
     for x in [1, 4.0, True, False]:
         with self.assertRaises(TypeError):
             validate_parameter('order', x)
コード例 #2
0
 def test_topRange_invalid(self):
     for x in ['1m', 'ascending', '1', '4M', '1Y']:
         with self.assertRaises(ValueError):
             validate_parameter('topRange', x)
     for x in [1, 4.0, True, False]:
         with self.assertRaises(TypeError):
             validate_parameter('topRange', x)
コード例 #3
0
 def test_validate_non_string(self):
     for x in [1, 4.0, None]:
         with self.assertRaises(TypeError):
             validate_parameter('test', x)
         with self.assertRaises(TypeError):
             validate_parameter(x, 'test')
         with self.assertRaises(TypeError):
             validate_parameter(x, x)
コード例 #4
0
 def test_q_invalid(self):
     for x in ['id:14 +tree', 'green like:123abc', 'id:4r']:
         with self.assertRaises(ValueError):
             validate_parameter('q', x)
コード例 #5
0
 def test_q_valid(self):
     for x in ['tree', '+tree', 'like:123abc', 'id:54']:
         self.assertEqual(('q', x), validate_parameter('q', x))
コード例 #6
0
 def test_topRange_valid(self):
     for x in ['1d', '3d', '1w', '1M', '3M', '6M', '1y']:
         self.assertEqual(('topRange', x),
                          validate_parameter('topRange', x))
コード例 #7
0
 def test_order_valid(self):
     for x in ['asc', 'desc']:
         self.assertEqual(('order', x), validate_parameter('order', x))
コード例 #8
0
 def test_category_invalid(self):
     for x in ['1111', '1', '2', '11']:
         with self.assertRaises(ValueError):
             validate_parameter('categories', x)
コード例 #9
0
 def test_categories_valid(self):
     for x in ['000', '001', '010', '011', '100', '101', '110', '111']:
         self.assertEqual(('categories', x),
                          validate_parameter('categories', x))
コード例 #10
0
 def test_purity_invalid(self):
     for x in ['1111', '1', '2', '11']:
         with self.assertRaises(ValueError):
             validate_parameter('purity', x)
コード例 #11
0
 def test_purity_valid(self):
     for x in ['000', '001', '010', '011', '100', '101', '110', '111']:
         self.assertEqual(('purity', x), validate_parameter('purity', x))