コード例 #1
0
 def test_update_a_promotion(self):
     """ Update a Promotion """
     promotion = Promotion("A1234", "BOGO", True, "20")
     promotion.save()
     self.assertNotEqual(promotion.id, None)
     # Change it an save it
     promotion.category = "Percentage"
     promotion.save()
     # 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].category, "Percentage")
     self.assertEqual(promotions[0].productid, "A1234")
コード例 #2
0
ファイル: test_models.py プロジェクト: makeapp007/promotions
 def test_update_a_promotion(self):
     """ Update a promotion in the database """
     promotion = Promotion(promo_name="random",
                           goods_name="random_good",
                           category="random_category",
                           price=20,
                           discount=20,
                           available=True)
     promotion.save()
     self.assertEqual(promotion.id, 1)
     #change it and save it
     promotion.category = "random_afterchange"
     promotion.save()
     self.assertEqual(promotion.id, 1)
     #Fetch it back to make sure the id not changed, but only the data
     promotions = Promotion.all()
     self.assertEqual(len(promotions), 1)
     self.assertEqual(promotions[0].category, "random_afterchange")