Skip to content

Commit

Permalink
wrote unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahxdu committed Oct 31, 2023
1 parent e024513 commit ecf7458
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions backend/tests/graphql/test_meal_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,68 @@ def test_create_meal_request(graphql_schema):
)


def test_update_meal_request(graphql_schema):
mutation = """
mutation testUpdateMealRequest {
updateMealRequest(
deliveryInstructions: "Leave at front door",
description: "Meal requests for charity",
dropOffLocation: "123 Main Street",
donationDatetime: "2023-10-31T16:45:00+00:00",
mealInfo: {portions: 40,
dietaryRestrictions: "7 gluten free, 7 no beef",
mealSuggestions: "Burritos"},
onsiteStaff: [
{name: "John Doe", email: "[email protected]", phone: "+1234567890"},
{name: "Jane Smith", email: "[email protected]", phone: "+9876543210"}],
requestor: "507f1f77bcf86cd799439011",
)
{
mealRequests {
status
description
id
donationDatetime
mealInfo {
portions
dietaryRestrictions
mealSuggestions
}
}
}
}
"""

result = graphql_schema.execute(mutation)

assert result.errors is None
assert result.data["updateMealRequest"]["mealRequests"][0]["status"] == "Open"
assert (
result.data["updateMealRequest"]["mealRequests"][0]["description"]
== "Meal requests for office employees"
)
assert (
result.data["updateMealRequest"]["mealRequests"][0]["mealInfo"]["portions"]
== 40
)
assert (
result.data["updateMealRequest"]["mealRequests"][0]["mealInfo"][
"dietaryRestrictions"
]
== "7 gluten free, 7 no beef"
)
assert (
result.data["updateMealRequest"]["mealRequests"][0]["mealInfo"][
"mealSuggestions"
]
== "Burritos"
)
assert (
result.data["updateMealRequest"]["mealRequests"][1]["donationDatetime"]
== "2023-10-31T16:45:00+00:00"
)


def test_get_meal_request_failure(graphql_schema):
mutation = """
mutation testCreateMealRequest {
Expand Down

0 comments on commit ecf7458

Please sign in to comment.