Exemplo n.º 1
0
def get_offer(offer_id):
    try:
        offer = Offer.find_by_id(offer_id)
        if offer:
            return dumps(offer.as_json()), 200
        else:
            return dumps({"Error": "Offer Not found"}), 400
    except Exception as e:
        print(e.message)
        print(traceback.print_exc())
        return dumps(e.message), 400
Exemplo n.º 2
0
def update_offer(offer_id):
    try:
        offer_hash = get_offer_json_attr_from_hash(request.json)
        offer = Offer.find_by_id(offer_id)
        if offer:
            offer = offer.update_offer_details(offer_hash)
            return dumps(offer.as_json()), 200
        else:
            return dumps({"Error": "Offer Not found"}), 400
    except Exception as e:
        print(e.message)
        print(traceback.print_exc())
        return dumps(e.message), 400
Exemplo n.º 3
0
 def test_should_return_None_by_find_by_offer_id(self):
     offer = Offer.find_by_id("some_wrong_offer_id")
     self.assertEqual(None, offer)
Exemplo n.º 4
0
 def test_should_return_offer_by_find_by_offer_id(self):
     offer = Offer.find_by_id(self.offer.offer_id)
     self.assertEqual(self.offer, offer)