Exemplo n.º 1
0
def test_update_mealplan(api_client: TestClient, api_routes: AppRoutes, slug_1,
                         slug_2, token):

    response = api_client.get(api_routes.meal_plans_all, headers=token)

    existing_mealplan = json.loads(response.text)
    existing_mealplan = existing_mealplan[0]

    # Swap
    plan_uid = existing_mealplan.get("uid")
    existing_mealplan["meals"][0]["slug"] = slug_2
    existing_mealplan["meals"][1]["slug"] = slug_1

    response = api_client.put(api_routes.meal_plans_plan_id(plan_uid),
                              json=existing_mealplan,
                              headers=token)

    assert response.status_code == 200

    response = api_client.get(api_routes.meal_plans_all, headers=token)
    existing_mealplan = json.loads(response.text)
    existing_mealplan = existing_mealplan[0]

    assert existing_mealplan["meals"][0]["slug"] == slug_2
    assert existing_mealplan["meals"][1]["slug"] == slug_1
Exemplo n.º 2
0
def test_delete_mealplan(api_client: TestClient, api_routes: AppRoutes, token):
    response = api_client.get(api_routes.meal_plans_all, headers=token)

    assert response.status_code == 200
    existing_mealplan = json.loads(response.text)
    existing_mealplan = existing_mealplan[0]

    plan_uid = existing_mealplan.get("uid")
    response = api_client.delete(api_routes.meal_plans_plan_id(plan_uid),
                                 headers=token)

    assert response.status_code == 200