-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.py
56 lines (46 loc) · 2.08 KB
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from __future__ import print_function
import requests
import json
import sys
import os
addr = 'http://127.0.0.1:5000'
#user registers
signup_url = addr + '/signUp'
response = requests.post(signup_url, params={"email": "[email protected]", "password": "password", "genre": "Action", "maxDistance": 2, "maxPrice": 30})
print("Response is", response)
print(json.loads(response.text))
#user raises a login request and begins the session
login_url = addr + '/login'
response = requests.post(login_url, params={'username': '[email protected]', 'password': 'password'})
print("Login Response is", response)
print(json.loads(response.text))
#user chooses from the list of shows displayed using index linked to the select button
show_url = addr + '/show'
response = requests.get(show_url, params={'index': 0})
print("Show Response is", response)
print(json.loads(response.text))
#user chooses number of slots and the food quantity for the selected show
show_url = addr + '/show'
food_quantity_list =[1,1]
response = requests.post(show_url, params={'num_slots': 1,'food_quantity_list:0': 1, 'food_quantity_list:1': 1})
print("Show Total Cost Response is", response)
print(json.loads(response.text))
#user raises request to update their preferences
purchase_url = addr + '/purchase'
response = requests.post(purchase_url, params={'cardNumber': '100000000000000', 'securityCode': '3333', 'expireDate': '02/20' , 'cardType':'debit'})
print("Update purchase Response is", response)
print(json.loads(response.text))
#user raises request to view their profile dashboard which contains current preferences and purchase history
dashboard_url = addr + '/dashboard'
response = requests.get(dashboard_url)
print("Daskboard Response is", response)
print(json.loads(response.text))
#user raises request to cancel their purchase
preferences_url = addr + '/cancelPurchase'
response = requests.post(preferences_url, params={'index': 0})
print("Deleted Purchase Response is", response)
print(json.loads(response.text))
#user ends his session
signOut_url = addr + '/signOut'
response = requests.post(signOut_url)
print("Sign out Response is", response)