From 7fdc9c7cb89f17a5cc5a5d286488b90599b8c9cf Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Thu, 14 Jul 2022 10:30:45 +0200 Subject: [PATCH] added sharing permission test --- cookbook/tests/api/test_api_recipe.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cookbook/tests/api/test_api_recipe.py b/cookbook/tests/api/test_api_recipe.py index e33dbdfe8..3d665a167 100644 --- a/cookbook/tests/api/test_api_recipe.py +++ b/cookbook/tests/api/test_api_recipe.py @@ -106,6 +106,22 @@ def test_update(arg, request, recipe_1_s1): validate_recipe(j, json.loads(r.content)) +def test_update_share(u1_s1, u2_s1, u1_s2, recipe_1_s1): + with scopes_disabled(): + r = u1_s1.patch( + reverse( + DETAIL_URL, + args={recipe_1_s1.id} + ), + {'shared': [{'id': auth.get_user(u1_s2).pk, 'username': auth.get_user(u1_s2).username}, {'id': auth.get_user(u2_s1).pk, 'username': auth.get_user(u2_s1).username}]}, + content_type='application/json' + ) + response = json.loads(r.content) + assert r.status_code == 200 + assert len(response['shared']) == 1 + assert response['shared'][0]['id'] == auth.get_user(u2_s1).pk + + def test_update_private_recipe(u1_s1, u2_s1, recipe_1_s1): r = u1_s1.patch(reverse(DETAIL_URL, args={recipe_1_s1.id}), {'name': 'test1'}, content_type='application/json') assert r.status_code == 200