Exemple #1
0
 def test_key_error_on_update(self, bad_mock):
     """ Test KeyError on update """
     bad_mock.side_effect = KeyError()
     promotion = Promotion("A002", "dog", False)
     promotion.save()
     promotion.productid = 'Fifi'
     promotion.update()
Exemple #2
0
 def test_update_a_promotion_fail(self):
     promotion = Promotion(
         title="test_create",
         promo_type=PromoType.DISCOUNT,
         amount=10,
         start_date=datetime(2020, 10, 17),
         end_date=datetime(2020, 10, 18),
         is_site_wide=True,
     )
     try:
         promotion.update()
     except:
         print("Update called with empty ID field")
Exemple #3
0
 def test_update_a_promotion(self):
     """ Update a Promotion """
     promotion = Promotion(
         title="test_create",
         promo_type=PromoType.DISCOUNT,
         amount=10,
         start_date=datetime(2020, 10, 17),
         end_date=datetime(2020, 10, 18),
         is_site_wide=True,
     )
     promotion.create()
     self.assertEqual(promotion.id, 1)
     # Change it and update it
     promotion.title = "test_update"
     promotion.update()
     self.assertEqual(promotion.id, 1)
     # Fetch it back and make sure the id hasn't changed
     # but the data did change
     promotions = Promotion.all()
     self.assertEqual(len(promotions), 1)
     self.assertEqual(promotions[0].title, "test_update")