def test_filter_by_name(self): try: cat = product.filter_categories(None, { "name": "--default--" }) except Fault: self.fail(AssertMessage.UNEXCEPT_ERROR) else: self.assertIsNotNone(cat) self.assertEqual(cat[0]['name'], "--default--")
def test_filter_by_product_id(self): cat = product.filter_categories(None, {'product': self.product.pk}) self.assertIsNotNone(cat) # PostgreSQL returns data in arbitrary order category_names = [c['name'] for c in cat] self.assertEqual(3, len(category_names)) self.assertIn('--default--', category_names) self.assertIn('auto', category_names) self.assertIn('manual', category_names)
def test_filter_by_product_id(self): cat = product.filter_categories(None, {'product': self.product.pk}) self.assertIsNotNone(cat) # PostgreSQL returns data in arbitrary order category_names = [c['name'] for c in cat] self.assertEqual(3, len(category_names)) self.assertIn('--default--', category_names) self.assertIn('auto', category_names) self.assertIn('manual', category_names)
def test_filter_by_product_id(self): cat = product.filter_categories(None, {'product': self.product.pk}) self.assertIsNotNone(cat) self.assertEqual(cat[0]['name'], '--default--') self.assertEqual(cat[1]['name'], 'auto') self.assertEqual(cat[2]['name'], 'manual')
def test_filter_by_product_name(self): cat = product.filter_categories(None, {'name': 'auto'}) self.assertIsNotNone(cat) self.assertEqual(cat[0]['name'], 'auto')
def test_filter_by_product_id(self): cat = product.filter_categories(None, {'product': self.product.pk}) self.assertIsNotNone(cat) self.assertEqual(cat[0]['name'], '--default--') self.assertEqual(cat[1]['name'], 'auto') self.assertEqual(cat[2]['name'], 'manual')