spruhaN / nutrition_pal

1 stars 1 forks source link

Test Results (Sam Todd) #9

Open SamuelTodd opened 4 months ago

SamuelTodd commented 4 months ago

Example Flow 1: Creating user and going above calorie goal

Create user:

  1. curl -X 'POST' \ 'https://nutrition-pal.onrender.com/user' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "name": "Sam", "weight": 72, "height": 200 }'
  2. { "id": 45 }

Create goal:

  1. curl -X 'POST' \ 'https://nutrition-pal.onrender.com/goals/45' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "goal": "Gain 15 pounds", "type": "Bulk", "daily_calories": 2500 }'
  2. "OK"

Create meal 1:

  1. curl -X 'POST' \ 'https://nutrition-pal.onrender.com/meal/45' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "name": "Burger", "calories": 1000 }'
  2. "OK"

Create meal 2:

  1. curl -X 'POST' \ 'https://nutrition-pal.onrender.com/meal/45' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "name": "Fries", "calories": 300 }'
  2. "OK"

Create meal 3:

  1. curl -X 'POST' \ 'https://nutrition-pal.onrender.com/meal/45' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "name": "Milkshake", "calories": 1300 }'
  2. "OK"

Get calorie goal

  1. curl -X 'GET' \ 'https://nutrition-pal.onrender.com/daily_calories/45' \ -H 'accept: application/json'
  2. { "calories_left": -100 }

Depending on how you want to handle going above your calorie goal, you may want to return something other than negative calorie number. However, the endpoints do work as intended and calculate calories remaining correctly.

Example Flow 2: Multiple conflicting goals

Create user:

  1. curl -X 'POST' \ 'https://nutrition-pal.onrender.com/user' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "name": "Todd", "weight": 60, "height": 150 }'
  2. { "id": 46 }

Create goal 1:

  1. curl -X 'POST' \ 'https://nutrition-pal.onrender.com/goals/46' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "goal": "Gain 10 pounds", "type": "Bulk", "daily_calories": 2200 }'
  2. "OK"

Create goal 2:

  1. curl -X 'POST' \ 'https://nutrition-pal.onrender.com/goals/46' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "goal": "Lose 10 pounds", "type": "Cut", "daily_calories": 1200 }'
  2. "OK"

Get calorie goal:

  1. curl -X 'GET' \ 'https://nutrition-pal.onrender.com/daily_calories/46' \ -H 'accept: application/json'
  2. { "calories_left": 2200 }

The application defaults to the first goal created by the user. It does not reference the second goal that was created for the same customer. I am not sure how conflicting calorie goals are meant to be handled, but if you are allowed to create multiple then there should be some restrictions. Instead of allowing the user to type out the type of the goal, maybe force them to select from a drop-down list of options so that only one of each type could be created at a time.

Example Flow 3: Get daily calories without creating a goal

Create user:

  1. curl -X 'POST' \ 'https://nutrition-pal.onrender.com/user' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "name": "Joseph", "weight": 66, "height": 175 }'
  2. { "id": 47 }

Get calorie goal:

  1. curl -X 'GET' \ 'https://nutrition-pal.onrender.com/daily_calories/47' \ -H 'accept: application/json'
  2. Internal Server Error

If you attempt to retrieve the current status of your calorie goal without creating a goal beforehand, it results in a server error. Some logic should be put in place to handle this. For example, you may want to raise an exception that instructs the user to create a goal.