def test_update(arg, request, recipe_1_s1): with scopes_disabled(): c = request.getfixturevalue(arg[0]) j = get_random_json_recipe() r = c.patch(reverse(DETAIL_URL, args={recipe_1_s1.id}), j, content_type='application/json') response = json.loads(r.content) assert r.status_code == arg[1] if r.status_code == 200: validate_recipe(j, json.loads(r.content))
def test_recipe_import(arg, u1_s1): url = arg['url'] for f in list(arg['file']): # url and files get popped later if 'cookbook' in os.getcwd(): test_file = os.path.join(os.getcwd(), 'other', 'test_data', f) else: test_file = os.path.join(os.getcwd(), 'cookbook', 'tests', 'other', 'test_data', f) with open(test_file, 'r', encoding='UTF-8') as d: response = u1_s1.post(reverse(IMPORT_SOURCE_URL), { 'data': d.read(), 'url': url, }, content_type='application/json') recipe = json.loads(response.content)['recipe_json'] validate_recipe(arg, recipe)
def test_add(arg, request, u1_s2): x = 0 while x < 2: c = request.getfixturevalue(arg[0]) j = get_random_json_recipe() r = c.post(reverse(LIST_URL), j, content_type='application/json') response = json.loads(r.content) print(r.content) assert r.status_code == arg[1] if r.status_code == 201: # id can change when running multiple tests, changed to validate name validate_recipe(j, json.loads(r.content)) r = c.get(reverse(DETAIL_URL, args={response['id']})) assert r.status_code == 200 r = u1_s2.get(reverse(DETAIL_URL, args={response['id']})) assert r.status_code == 404 x += 1