Luke-Fanguna / FoodForLesser

0 stars 0 forks source link

Test Results (Wesley Tam) #35

Open wesleytam88 opened 10 months ago

wesleytam88 commented 10 months ago

Example Flow 1

LilNHo is a helpful citizen, LilNHo finds eggs for half off deal at Costco and wants to share his find with others! He opens up Food4Lesser and creates a new grocery price posting for everyone to see. In his excitement, he accidentally makes a typo. He quickly updates the price of his post and goes on with shopping. Later when he is leaving, he realizes many people saw his post and came to Costco to buy eggs. With the eggs sold out, he deletes his posting so no one else comes to Costco disappointed. Starts by calling POST /crowdsourcing/{store_id}/{grocery_id}/upload/{grocery_price} to share the deal he found. Then he calls PUT /crowdsourcing/{posting_id}/update/{grocery_price} when he realizes he made a typo and wants to update the price of his posting. Last, he calls DELETE /crowdsourcing/{posting_id}/delete when he finds there are no more eggs.

Sharing deal

curl -X 'POST' \
  'https://food-for-lesser.onrender.com/crowdsourcing/1/upload/1/1/5?inventory_levels=medium' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
28

Update price

curl -X 'PUT' \
  'https://food-for-lesser.onrender.com/crowdsourcing/28/update/3' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key'

Response Body:
"OK"

Deleting deal

curl -X 'DELETE' \
  'https://food-for-lesser.onrender.com/crowdsourcing/28/delete' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key'

Response Body:
"OK"

Example Flow 2

Josh lives with 3 of his friends and is looking for a way to grocery shop efficiently for the household. He discovers FoodForLesser and is ecstatic! First, Josh creates his grocery list by calling POST /lists. He then adds a list of items into his grocery list. To do so he: calls POST /lists/1/items/chicken_breast to add chicken breast for the gains Calls POST /lists/1/items/milk to add milk to his list Calls POST /lists/1/items/cheese to add cheese to his list Calls POST /lists/1/items/tomato to add tomato to his list Finally, he calls POST /stores/1/distribute to get the cheapest store for each item in his list Now with his distributed list of grocery items with their respective store(s), he and his roommates can effectively split up their grocery needs, in which each roommate can go to one grocery store and get the item that is cheapest there.

Create grocery list

curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/?user_id=1' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body: 
{
  "list_id": 16
}

Add items to grocery list

curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/16/items/1/1' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
{
  "posting_id": 37
}
curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/16/items/2/1' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
{
  "posting_id": 38
}
curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/16/items/3/1' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
{
  "posting_id": 39
}
curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/16/items/4/1' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
{
  "posting_id": 40
}

Distributing list

curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/stores/16/distribute (POST)' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
[
  {
    "Store": "Costco",
    "Item": "Ketchup",
    "Price": 4
  },
  {
    "Store": "Ralphs",
    "Item": "Hotdogs",
    "Price": 0
  },
  {
    "Store": "Costco",
    "Item": "Bread",
    "Price": 2
  },
  {
    "Store": "Grocery Outlet",
    "Item": "Doritos",
    "Price": 3
  }
]

Example Flow 3

Misaki is a single mother. She wants to find a store that is close by with cheap groceries so her and her child won’t starve. She desperately needs baby food and caffeine. She requests a list of stores near her location by calling GET /stores. This gives her a list of stores within ten miles of her. She then makes her own grocery list by calling POST /lists. She wants to add coffee, baby food, and top ramen to her list and find the grocery store where the total cost of her list would be the cheapest. To do so she: Calls POST /lists/1/items/coffee to add coffee to her list Calls POST /lists/1/items/baby_food to add baby food to her list Calls POST /lists/1/items/top_ramen to add top ramen to her list Finally, she calls POST /stores/1/best which will give her the store that would give her the cheapest list

Get stores nearby

curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/stores/ (GET)' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
[
  {
    "id": 1,
    "name": "Safeway"
  },
  {
    "id": 2,
    "name": "Ralphs"
  },
  {
    "id": 3,
    "name": "Costco"
  },
  {
    "id": 4,
    "name": "Smart & Final"
  },
  {
    "id": 5,
    "name": "Grocery Outlet"
  }
]

Create grocery list

curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/?user_id=1' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
{
  "list_id": 17
}

Add grocery items to list

curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/17/items/5/1' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
{
  "posting_id": 41
}
curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/17/items/6/3' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
{
  "posting_id": 42
}
curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/17/items/7/4' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
{
  "posting_id": 43
}

Finding best store

curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/stores/17/best (POST)' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
Internal Server Error

Wesley Test Flow 1:

Wesley wants to do his weekly grocery shopping at one story because he is busy. He creates a grocery list with POST /lists. He then adds 1 ketchup POST /lists/{list_id}/items/1/1 and 2 hotdogs POST /lists/{list_id}/items/2/2 to the list. Wesley then changes his mind and decides to update his list to buy 4 hotdogs with PUT /lists/{posting_id}/items/4. He makes sure the change went through with GET /lists/{list_id}. Finally, he uses POST lists/stores/{list_id}/best to determine which store he should go to.

Create list

curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/?user_id=1' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body: 
{
  "list_id": 18
}

Add items to list

curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/18/items/1/1' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
{
  "posting_id": 44
}
curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/18/items/2/2' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
{
  "posting_id": 45
}

Update list

curl -X 'PUT' \
  'https://food-for-lesser.onrender.com/lists/45/items/4' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key'

Response Body:
"OK"

Get list

curl -X 'GET' \
  'https://food-for-lesser.onrender.com/lists/18' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key'

Response Body:
[
  {
    "item_id": 1,
    "item": "Ketchup",
    "quantity": 1
  },
  {
    "item_id": 2,
    "item": "Hotdogs",
    "quantity": 4
  }
]

Find best store

curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/stores/18/best (POST)' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
Internal Server Error

Wesley Test Flow 2:

Wesley decides he wants bread and doritos. He creates a new grocery list with POST /lists and adds bread and doritos with POST /lists/{list_id}/items/3/1 and POST /lists/{list_id}/items/4/99 respectively. He uses POST lists/stores/{list_id}/best to find the best store to shop from. He then suddenly realizes he probably shouldn't but 99 doritos, so he deletes the doritos from his list with DELETE /lists/{posting_id}/items/, uses GET /lists/{list_id} to make sure the change went through, and reruns POST lists/stores/{list_id}/best to find the best shop.

Create list

curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/?user_id=1' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
{
  "list_id": 19
}

Add items to grocery list

curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/19/items/3/1' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
{
  "posting_id": 46
}
curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/19/items/4/99' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
{
  "posting_id": 47
}

Find best store

curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/stores/19/best (POST)' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
Internal Server Error

Delete item from list

curl -X 'DELETE' \
  'https://food-for-lesser.onrender.com/lists/47/items/' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key'

Response Body:
"OK"

Get list

curl -X 'GET' \
  'https://food-for-lesser.onrender.com/lists/19' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key'

Response Body:
[
  {
    "item_id": 3,
    "item": "Bread",
    "quantity": 1
  }
]

Find best store:

curl -X 'POST' \
  'https://food-for-lesser.onrender.com/lists/stores/19/best (POST)' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
Internal Server Error

Wesley Test Flow 3:

At Costco, Wesley sees that the Costco hot dog is now $1.00. After making sure he is not dreaming, he shares this incredible deal on Food4Lesser using POST /crowdsourcing/{user_id}/upload/3/2/1. Unknown to Wesley, Josh also shares the deal on Food4Lesser, duplicating the deal.

Wesley's upload

curl -X 'POST' \
  'https://food-for-lesser.onrender.com/crowdsourcing/1/upload/3/2/1?inventory_levels=medium' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
29

Josh's upload:

curl -X 'POST' \
  'https://food-for-lesser.onrender.com/crowdsourcing/2/upload/3/2/1?inventory_levels=medium' \
  -H 'accept: application/json' \
  -H 'access_token: demo-key' \
  -d ''

Response Body:
30

Two different id's were returned, so I am assuming the deal was duplicated now. To fix this, check if the store_id, item_id, and price are already attributed to a sample in the database. If so, do not add/duplicate the deal.