fixed recipe tests paths and edit max switch

This commit is contained in:
vabene1111
2021-05-30 09:27:20 +02:00
parent 14ca61b11f
commit 505b60cb14
3 changed files with 7 additions and 3 deletions

View File

@ -14,6 +14,7 @@ def test_switch_recipe(u1_s1, recipe_1_s1, space_1):
url = reverse('edit_recipe', args=[recipe_1_s1.pk])
r = u1_s1.get(url)
print(r)
assert r.status_code == 302
r = u1_s1.get(r.url)

View File

@ -55,6 +55,9 @@ def test_import_permission(arg, request):
])
def test_recipe_import(arg, u1_s1):
for f in arg['file']:
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(

View File

@ -45,11 +45,11 @@ def convert_recipe(request, pk):
@group_required('user')
def internal_recipe_update(request, pk):
if Recipe.objects.filter(space=request.space).count() > request.space.max_recipes:
if request.space.max_recipes != 0 and Recipe.objects.filter(space=request.space).count() > request.space.max_recipes:
messages.add_message(request, messages.WARNING, _('You have reached the maximum number of recipes for your space.'))
return HttpResponseRedirect(reverse('view_recipe', args=[pk]))
if UserPreference.objects.filter(space=request.space).count() > request.space.max_users:
if request.space.max_users != 0 and UserPreference.objects.filter(space=request.space).count() > request.space.max_users:
messages.add_message(request, messages.WARNING, _('You have more users than allowed in your space.'))
return HttpResponseRedirect(reverse('view_recipe', args=[pk]))