<reponame>JLambertazzo/SeeFood
import requests
import uuid

BASE = "http://127.0.0.1:5000/"

# create two restaurants
response = requests.post(BASE + "api/restaurants", {
  "name": "my aaaaaaarestaurant",
  "password": "<PASSWORD>",
  "description": "description of my restaurant"
})
other_response = requests.post(BASE + "api/restaurants", {
  "name": "my aaaaaaaother restaurant",
  "password": "<PASSWORD>",
  "description": "description of my restaurant"
})
rest_id = response.json()['id']
other_rest_id = other_response.json()['id']
print('successfully created' + rest_id + ' & ' + other_rest_id)

# update the restaurant
response2 = requests.patch(BASE + f"api/restaurants/{rest_id}", {
  "name": "updated restaurant",
  "description": "new updated description"
})
print(response2.json())

# try logging in as the restaurant
response21 = requests.get(BASE + "api/restaurants", {
  "name": "updated restaurant",
  "password": "<PASSWORD>"
})
print('login attempt gives us:' + response21.json()['id'])

# delete the restaurant
response3 = requests.delete(BASE + f"api/restaurants/{rest_id}")
print(response3.json())

# check if the restaurant is gone
response4 = requests.get(BASE + f"api/restaurants/{rest_id}")
print(response4.json())

print('==== END OF RESTAURANT TESTS ====')

# create meal
item_response = requests.post(BASE + f"api/item", {
  "restaurant": other_rest_id,
  "name": "aaaaameal",
  "description": "a description",
  "ingredients": "an ingredient",
})
mid = item_response.json()['id']
print('successfully created ' + mid)

# update meal
item_response2 = requests.patch(BASE + f"api/item/{mid}", {
  "name": "an updated meal"
})
print(item_response2.json())

# check if still exists
item_response4 = requests.get(BASE + f"api/item/{mid}")
print(item_response4.json())

# # delete meal
# item_response3 = requests.delete(BASE + f"api/item/{mid}")
# print(item_response3.json())

# check if still exists
item_response4 = requests.get(BASE + f"api/item/{mid}")
print(item_response4.json())
import requests
import uuid

BASE = "http://127.0.0.1:5000/"

# create two restaurants
response = requests.post(BASE + "api/restaurants", {
  "name": "my aaaaaaarestaurant",
  "password": "<PASSWORD>",
  "description": "description of my restaurant"
})
other_response = requests.post(BASE + "api/restaurants", {
  "name": "my aaaaaaaother restaurant",
  "password": "<PASSWORD>",
  "description": "description of my restaurant"
})
rest_id = response.json()['id']
other_rest_id = other_response.json()['id']
print('successfully created' + rest_id + ' & ' + other_rest_id)

# update the restaurant
response2 = requests.patch(BASE + f"api/restaurants/{rest_id}", {
  "name": "updated restaurant",
  "description": "new updated description"
})
print(response2.json())

# try logging in as the restaurant
response21 = requests.get(BASE + "api/restaurants", {
  "name": "updated restaurant",
  "password": "<PASSWORD>"
})
print('login attempt gives us:' + response21.json()['id'])

# delete the restaurant
response3 = requests.delete(BASE + f"api/restaurants/{rest_id}")
print(response3.json())

# check if the restaurant is gone
response4 = requests.get(BASE + f"api/restaurants/{rest_id}")
print(response4.json())

print('==== END OF RESTAURANT TESTS ====')

# create meal
item_response = requests.post(BASE + f"api/item", {
  "restaurant": other_rest_id,
  "name": "aaaaameal",
  "description": "a description",
  "ingredients": "an ingredient",
})
mid = item_response.json()['id']
print('successfully created ' + mid)

# update meal
item_response2 = requests.patch(BASE + f"api/item/{mid}", {
  "name": "an updated meal"
})
print(item_response2.json())

# check if still exists
item_response4 = requests.get(BASE + f"api/item/{mid}")
print(item_response4.json())

# # delete meal
# item_response3 = requests.delete(BASE + f"api/item/{mid}")
# print(item_response3.json())

# check if still exists
item_response4 = requests.get(BASE + f"api/item/{mid}")
print(item_response4.json())
# create two restaurants # update the restaurant # try logging in as the restaurant # delete the restaurant # check if the restaurant is gone # create meal # update meal # check if still exists # # delete meal # item_response3 = requests.delete(BASE + f"api/item/{mid}") # print(item_response3.json()) # check if still exists