def test_search_products_all_fields(self): results = search_products(search_term='cfpb', search_field=[], products=PrepaidProduct.objects.all()) self.assertIn(self.product1, results) self.assertIn(self.product2, results) self.assertEqual(results.count(), 2)
def test_search_products_issuer_name(self): product1 = PrepaidProduct(issuer_name='Bank of CFPB') product1.save() product2 = PrepaidProduct(issuer_name='Bank of Foo Bar') product2.save() results = search_products(search_term='cfpb', search_field=['issuer_name'], products=PrepaidProduct.objects.all()) self.assertIn(product1, results) self.assertEqual(results.count(), 1)
def test_search_products_all_fields(self): product1 = PrepaidProduct(issuer_name='XYZ Bank') product1.save() product2 = PrepaidProduct(program_manager='xyz manager') product2.save() product3 = PrepaidProduct(name='Foo Bar Product') product3.save() results = search_products(search_term='Xyz', search_field=[], products=PrepaidProduct.objects.all()) self.assertIn(product1, results) self.assertIn(product2, results) self.assertEqual(results.count(), 2)