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)
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)
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)
def test_q_invalid(self): for x in ['id:14 +tree', 'green like:123abc', 'id:4r']: with self.assertRaises(ValueError): validate_parameter('q', x)
def test_q_valid(self): for x in ['tree', '+tree', 'like:123abc', 'id:54']: self.assertEqual(('q', x), validate_parameter('q', x))
def test_topRange_valid(self): for x in ['1d', '3d', '1w', '1M', '3M', '6M', '1y']: self.assertEqual(('topRange', x), validate_parameter('topRange', x))
def test_order_valid(self): for x in ['asc', 'desc']: self.assertEqual(('order', x), validate_parameter('order', x))
def test_category_invalid(self): for x in ['1111', '1', '2', '11']: with self.assertRaises(ValueError): validate_parameter('categories', x)
def test_categories_valid(self): for x in ['000', '001', '010', '011', '100', '101', '110', '111']: self.assertEqual(('categories', x), validate_parameter('categories', x))
def test_purity_invalid(self): for x in ['1111', '1', '2', '11']: with self.assertRaises(ValueError): validate_parameter('purity', x)
def test_purity_valid(self): for x in ['000', '001', '010', '011', '100', '101', '110', '111']: self.assertEqual(('purity', x), validate_parameter('purity', x))