fix categories in supermarket edit modal

This commit is contained in:
smilerz
2021-12-21 13:40:50 -06:00
parent dfe414985b
commit 42132568c4
6 changed files with 22 additions and 10 deletions

View File

@@ -4,9 +4,10 @@ from datetime import datetime, timedelta
import pytest
from django.contrib import auth
from django.urls import reverse
from django_scopes import scopes_disabled
from django_scopes import scope, scopes_disabled
from cookbook.models import Food, MealPlan, MealType
from cookbook.tests.factories import RecipeFactory
LIST_URL = 'api:mealplan-list'
DETAIL_URL = 'api:mealplan-detail'
@@ -141,3 +142,17 @@ def test_delete(u1_s1, u1_s2, obj_1):
assert r.status_code == 204
with scopes_disabled():
assert MealPlan.objects.count() == 0
def test_add_with_shopping(u1_s1, meal_type):
space = meal_type.space
with scope(space=space):
recipe = RecipeFactory.create(space=space)
r = u1_s1.post(
reverse(LIST_URL),
{'recipe': {'id': recipe.id, 'name': recipe.name, 'keywords': []}, 'meal_type': {'id': meal_type.id, 'name': meal_type.name},
'date': (datetime.now()).strftime("%Y-%m-%d"), 'servings': 1, 'title': 'test', 'shared': [], 'addshopping': True},
content_type='application/json'
)
assert len(json.loads(u1_s1.get(reverse('api:shoppinglistentry-list')).content)) == 10

View File

@@ -224,3 +224,6 @@ def test_shopping_recipe_mixed_authors(u1_s1, u2_s1):
u1_s1.put(reverse(SHOPPING_RECIPE_URL, args={recipe1.id}))
assert len(json.loads(u1_s1.get(reverse(SHOPPING_LIST_URL)).content)) == 29
assert len(json.loads(u2_s1.get(reverse(SHOPPING_LIST_URL)).content)) == 0
# TODO test failing to adding recipe with ingredients that are not food