Beispiel #1
0
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')
Beispiel #2
0
 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())
Beispiel #3
0
 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))
Beispiel #4
0
 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))
Beispiel #5
0
 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))