def test_that_get_oneper_listing_by_product_returns_none(self): # turn on automatic listing creation on product creation old_setting_value = bazaar_settings.AUTOMATIC_LISTING_CREATION_ON_PRODUCT_CREATION bazaar_settings.AUTOMATIC_LISTING_CREATION_ON_PRODUCT_CREATION = False self.assertEqual(Listing.objects.count(), 0) product = ProductFactory() self.assertIsNone(get_oneper_listing_by_product(product)) bazaar_settings.AUTOMATIC_LISTING_CREATION_ON_PRODUCT_CREATION = old_setting_value
def test_that_get_oneper_listing_by_product_works_with_multiple_listings(self): """ Verify that only 1x product listing are returned """ # turn on automatic listing creation on product creation old_setting_value = bazaar_settings.AUTOMATIC_LISTING_CREATION_ON_PRODUCT_CREATION bazaar_settings.AUTOMATIC_LISTING_CREATION_ON_PRODUCT_CREATION = True self.assertEqual(Listing.objects.count(), 0) product = ProductFactory() # create a listing with 2 products composite = CompositeProductFactory() ProductSetFactory(product=product, composite=composite, quantity=1) ProductSetFactory(product=ProductFactory(), composite=composite, quantity=1) self.assertIsNotNone(get_oneper_listing_by_product(product)) bazaar_settings.AUTOMATIC_LISTING_CREATION_ON_PRODUCT_CREATION = old_setting_value