def order(): productList = Store() if request.method == 'POST': item = request.form['pizza_name'] quantity = int(request.form['quantity']) price = productList.getPrize(item) amount = price * quantity print(amount) # Create a new resource response = requests.post( 'https://siddhi4.bpmcep.ics.unisg.ch/engine-rest/process-definition/key/payment-retrieval/start', json={ "variables": { "amount": { "value": amount, "type": "long" }, "item": { "value": item, "type": "string" } } }) print(response.content) if response.status_code == 200: jsonResponse = response.json() instanceID = jsonResponse.get("id") else: instanceID = "null" return render_template('response.html', item=item, amount=amount, quantity=quantity,code=response.status_code, instanceID=instanceID,message=response.content) return render_template('order.html')
def test_total_income(self): my_store = Store("Ardes") new_laptop = Laptop('HP HackBook', 1000, 1243, 1000, 4) my_store.load_new_products(new_laptop, 20) my_store.sell_product(new_laptop) self.assertEqual(243, my_store.total_income())
def test_sell_product_false(self): my_store = Store("Ardes") new_laptop = Laptop('HP HackBook', 1000, 1243, 1000, 4) my_store.load_new_products(new_laptop, 0) self.assertFalse(my_store.sell_product(new_laptop))
def test_list_product(self): my_store = Store("Ardes") new_laptop = Laptop('HP HackBook', 1000, 1243, 1000, 4) my_store.load_new_products(new_laptop, 20) self.assertEqual("HP HackBook - 20", my_store.list_products(Laptop))
def test_load_new_products_empty(self): my_store = Store("Ardes") new_laptop = Laptop('HP HackBook', 1000, 1243, 1000, 4) self.assertEqual(20, my_store.load_new_products(new_laptop, 20))