def test_redeem_promotion(self): """ Redeem a Promoion """ Promotion(name="20%OFF", product_id=9527, discount_ratio=80).save() promotion = Promotion.find(1) self.assertEqual(promotion.counter, 0) Promotion.redeem_promotion(1) self.assertEqual(promotion.counter, 1) Promotion.redeem_promotion(1) self.assertEqual(promotion.counter, 2)
def redeem_promotions(promotion_id): """ Redeem a Promotion This endpoint will increment the counter of a Promotion by 1. """ promotion = Promotion.redeem_promotion(promotion_id) return make_response(jsonify(promotion.serialize()), status.HTTP_200_OK)
def redeem_promotions(promotion_id): """ Redeems a Promotion This endpoint will increment the counter of a Promotion by 1. --- tags: - promotions parameters: - name: promotion_id in: path description: Numeric ID of the promotion to get required: true type: integer responses: 200: description: promotion redeemed schema: $ref: '#/definitions/ResponsePromotionObject' 404: description: promotion not found, object invalid """ promotion = Promotion.redeem_promotion(promotion_id) return make_response(jsonify(promotion.serialize()), status.HTTP_200_OK)