def test_update_a_recommendation(self): """ Update a Recommendation """ recommendation = Recommendation(product_id=PS4, recommended_product_id=CONTROLLER, recommendation_type="accessory") recommendation.save() # Change it an save it recommendation.product_id = PS3 recommendation.save() self.assertEqual(recommendation.id, 1) self.assertEqual(recommendation.product_id, PS3) # Fetch it back and make sure the id hasn't changed # but the data did change recommendations = Recommendation.all() self.assertEqual(len(recommendations), 1) self.assertEqual(recommendations[0].product_id, PS3)
def test_update_a_recommendation(self): """ Update a Recommendation """ data = { "product_id": 23, "rec_type_id": 1, "rec_product_id": 45, "weight": .5 } rec = Recommendation() rec.deserialize(data) rec.save() # self.assertEqual(rec.id, 1) # Change and save it rec.product_id = 54 rec.save() self.assertEqual(rec.product_id, 54) # Fetch it back and make sure the id hasn't changed # but the data did change rec = Recommendation.find_by_id(1) self.assertEqual(rec.product_id, 54)