From 2cd33ee40a0b393e2c94691be2f367299176ca5d Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Tue, 30 Nov 2021 17:20:36 +0100 Subject: [PATCH] fixed several tests --- cookbook/tests/api/test_api_meal_plan.py | 2 +- cookbook/tests/api/test_api_step.py | 8 ++++---- cookbook/tests/api/test_api_userpreference.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cookbook/tests/api/test_api_meal_plan.py b/cookbook/tests/api/test_api_meal_plan.py index cf5841622..37b52e88e 100644 --- a/cookbook/tests/api/test_api_meal_plan.py +++ b/cookbook/tests/api/test_api_meal_plan.py @@ -106,7 +106,7 @@ def test_add(arg, request, u1_s2, recipe_1_s1, meal_type): r = c.post( reverse(LIST_URL), {'recipe': {'id': recipe_1_s1.id, 'name': recipe_1_s1.name, 'keywords': []}, 'meal_type': {'id': meal_type.id, 'name': meal_type.name}, - 'date': (datetime.now()).strftime("%Y-%m-%d"), 'servings': 1, 'title': 'test'}, + 'date': (datetime.now()).strftime("%Y-%m-%d"), 'servings': 1, 'title': 'test','shared':[]}, content_type='application/json' ) response = json.loads(r.content) diff --git a/cookbook/tests/api/test_api_step.py b/cookbook/tests/api/test_api_step.py index c34b202a8..3b9dd8d7c 100644 --- a/cookbook/tests/api/test_api_step.py +++ b/cookbook/tests/api/test_api_step.py @@ -23,8 +23,8 @@ def test_list_permission(arg, request): def test_list_space(recipe_1_s1, u1_s1, u1_s2, space_2): - assert len(json.loads(u1_s1.get(reverse(LIST_URL)).content)) == 2 - assert len(json.loads(u1_s2.get(reverse(LIST_URL)).content)) == 0 + assert len(json.loads(u1_s1.get(reverse(LIST_URL)).content)['results']) == 2 + assert len(json.loads(u1_s2.get(reverse(LIST_URL)).content)['results']) == 0 with scopes_disabled(): recipe_1_s1.space = space_2 @@ -32,8 +32,8 @@ def test_list_space(recipe_1_s1, u1_s1, u1_s2, space_2): Step.objects.update(space=Subquery(Step.objects.filter(pk=OuterRef('pk')).values('recipe__space')[:1])) Ingredient.objects.update(space=Subquery(Ingredient.objects.filter(pk=OuterRef('pk')).values('step__recipe__space')[:1])) - assert len(json.loads(u1_s1.get(reverse(LIST_URL)).content)) == 0 - assert len(json.loads(u1_s2.get(reverse(LIST_URL)).content)) == 2 + assert len(json.loads(u1_s1.get(reverse(LIST_URL)).content)['results']) == 0 + assert len(json.loads(u1_s2.get(reverse(LIST_URL)).content)['results']) == 2 @pytest.mark.parametrize("arg", [ diff --git a/cookbook/tests/api/test_api_userpreference.py b/cookbook/tests/api/test_api_userpreference.py index 31bf7faf9..4750fbaa4 100644 --- a/cookbook/tests/api/test_api_userpreference.py +++ b/cookbook/tests/api/test_api_userpreference.py @@ -18,10 +18,10 @@ def test_add(u1_s1, u2_s1): with scopes_disabled(): UserPreference.objects.filter(user=auth.get_user(u1_s1)).delete() - r = u2_s1.post(reverse(LIST_URL), {'user': auth.get_user(u1_s1).id}, content_type='application/json') + r = u2_s1.post(reverse(LIST_URL), {'user': auth.get_user(u1_s1).id, 'plan_share': []}, content_type='application/json') assert r.status_code == 404 - r = u1_s1.post(reverse(LIST_URL), {'user': auth.get_user(u1_s1).id}, content_type='application/json') + r = u1_s1.post(reverse(LIST_URL), {'user': auth.get_user(u1_s1).id, 'plan_share': []}, content_type='application/json') assert r.status_code == 200