delete obsolete tests + fixes

This commit is contained in:
vabene1111
2025-01-19 18:35:23 +01:00
parent cba80aeac9
commit e8cbd91baf
4 changed files with 82 additions and 206 deletions

View File

@@ -1,83 +0,0 @@
from cookbook.models import Recipe, Storage
from django.contrib import auth
from django.urls import reverse
from pytest_django.asserts import assertTemplateUsed
def test_switch_recipe(u1_s1, recipe_1_s1, space_1):
external_recipe = Recipe.objects.create(
name='Test',
internal=False,
created_by=auth.get_user(u1_s1),
space=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)
assertTemplateUsed(r, 'forms/edit_internal_recipe.html')
url = reverse('edit_recipe', args=[external_recipe.pk])
r = u1_s1.get(url)
assert r.status_code == 302
r = u1_s1.get(r.url)
assertTemplateUsed(r, 'generic/edit_template.html')
def test_convert_recipe(u1_s1, space_1):
external_recipe = Recipe.objects.create(
name='Test',
internal=False,
created_by=auth.get_user(u1_s1),
space=space_1,
)
r = u1_s1.get(reverse('edit_convert_recipe', args=[external_recipe.pk]))
assert r.status_code == 302
external_recipe.refresh_from_db()
assert external_recipe.internal
def test_external_recipe_update(u1_s1, u1_s2, space_1):
storage = Storage.objects.create(
name='TestStorage',
method=Storage.DROPBOX,
created_by=auth.get_user(u1_s1),
token='test',
username='test',
password='test',
space=space_1,
)
recipe = Recipe.objects.create(
name='Test',
created_by=auth.get_user(u1_s1),
storage=storage,
space=space_1,
)
url = reverse('edit_external_recipe', args=[recipe.pk])
r = u1_s1.get(url)
assert r.status_code == 200
u1_s2.post(
url,
{'name': 'Test', 'working_time': 15, 'waiting_time': 15, 'servings': 1, }
)
recipe.refresh_from_db()
assert recipe.working_time == 0
assert recipe.waiting_time == 0
u1_s1.post(
url,
{'name': 'Test', 'working_time': 15, 'waiting_time': 15, 'servings': 1, }
)
recipe.refresh_from_db()
assert recipe.working_time == 15
assert recipe.waiting_time == 15

View File

@@ -2,81 +2,81 @@ import pytest
from django.urls import reverse
@pytest.mark.parametrize("arg", [
['a_u', 302],
['g1_s1', 302],
['u1_s1', 302],
['a1_s1', 302],
])
def test_index(arg, request, ext_recipe_1_s1):
c = request.getfixturevalue(arg[0])
assert c.get(reverse('index')).status_code == arg[1]
@pytest.mark.parametrize("arg", [
['a_u', 302],
['g1_s1', 200],
['u1_s1', 200],
['a1_s1', 200],
])
def test_search(arg, request, ext_recipe_1_s1):
c = request.getfixturevalue(arg[0])
assert c.get(reverse('view_search')).status_code == arg[1]
@pytest.mark.parametrize("arg", [
['a_u', 302],
['g1_s1', 302],
['u1_s1', 200],
['a1_s1', 200],
])
def test_books(arg, request, ext_recipe_1_s1):
c = request.getfixturevalue(arg[0])
assert c.get(reverse('view_books')).status_code == arg[1]
@pytest.mark.parametrize("arg", [
['a_u', 302],
['g1_s1', 302],
['u1_s1', 200],
['a1_s1', 200],
])
def test_plan(arg, request, ext_recipe_1_s1):
c = request.getfixturevalue(arg[0])
assert c.get(reverse('view_plan')).status_code == arg[1]
@pytest.mark.parametrize("arg", [
['a_u', 302],
['g1_s1', 302],
['u1_s1', 200],
['a1_s1', 200],
])
def test_shopping(arg, request, ext_recipe_1_s1):
c = request.getfixturevalue(arg[0])
assert c.get(reverse('view_shopping')).status_code == arg[1]
@pytest.mark.parametrize("arg", [
['a_u', 302],
['g1_s1', 200],
['u1_s1', 200],
['a1_s1', 200],
])
def test_settings(arg, request, ext_recipe_1_s1):
c = request.getfixturevalue(arg[0])
assert c.get(reverse('view_settings')).status_code == arg[1]
@pytest.mark.parametrize("arg", [
['a_u', 302],
['g1_s1', 200],
['u1_s1', 200],
['a1_s1', 200],
])
def test_history(arg, request, ext_recipe_1_s1):
c = request.getfixturevalue(arg[0])
assert c.get(reverse('view_history')).status_code == arg[1]
# @pytest.mark.parametrize("arg", [
# ['a_u', 302],
# ['g1_s1', 302],
# ['u1_s1', 302],
# ['a1_s1', 302],
# ])
# def test_index(arg, request, ext_recipe_1_s1):
# c = request.getfixturevalue(arg[0])
# assert c.get(reverse('index')).status_code == arg[1]
#
#
# @pytest.mark.parametrize("arg", [
# ['a_u', 302],
# ['g1_s1', 200],
# ['u1_s1', 200],
# ['a1_s1', 200],
# ])
# def test_search(arg, request, ext_recipe_1_s1):
# c = request.getfixturevalue(arg[0])
# assert c.get(reverse('view_search')).status_code == arg[1]
#
#
# @pytest.mark.parametrize("arg", [
# ['a_u', 302],
# ['g1_s1', 302],
# ['u1_s1', 200],
# ['a1_s1', 200],
# ])
# def test_books(arg, request, ext_recipe_1_s1):
# c = request.getfixturevalue(arg[0])
# assert c.get(reverse('view_books')).status_code == arg[1]
#
#
# @pytest.mark.parametrize("arg", [
# ['a_u', 302],
# ['g1_s1', 302],
# ['u1_s1', 200],
# ['a1_s1', 200],
# ])
# def test_plan(arg, request, ext_recipe_1_s1):
# c = request.getfixturevalue(arg[0])
# assert c.get(reverse('view_plan')).status_code == arg[1]
#
#
# @pytest.mark.parametrize("arg", [
# ['a_u', 302],
# ['g1_s1', 302],
# ['u1_s1', 200],
# ['a1_s1', 200],
# ])
# def test_shopping(arg, request, ext_recipe_1_s1):
# c = request.getfixturevalue(arg[0])
# assert c.get(reverse('view_shopping')).status_code == arg[1]
#
#
# @pytest.mark.parametrize("arg", [
# ['a_u', 302],
# ['g1_s1', 200],
# ['u1_s1', 200],
# ['a1_s1', 200],
# ])
# def test_settings(arg, request, ext_recipe_1_s1):
# c = request.getfixturevalue(arg[0])
# assert c.get(reverse('view_settings')).status_code == arg[1]
#
#
# @pytest.mark.parametrize("arg", [
# ['a_u', 302],
# ['g1_s1', 200],
# ['u1_s1', 200],
# ['a1_s1', 200],
# ])
# def test_history(arg, request, ext_recipe_1_s1):
# c = request.getfixturevalue(arg[0])
# assert c.get(reverse('view_history')).status_code == arg[1]
@pytest.mark.parametrize("arg", [

View File

@@ -1,45 +0,0 @@
import uuid
from django.urls import reverse
from django_scopes import scopes_disabled
from cookbook.helper.permission_helper import share_link_valid
from cookbook.models import ShareLink
def test_share(recipe_1_s1, u1_s1, a_u):
with scopes_disabled():
url = reverse('view_recipe', kwargs={'pk': recipe_1_s1.pk})
r = u1_s1.get(url)
assert r.status_code == 200
r = a_u.get(url)
assert r.status_code == 302
url = reverse('new_share_link', kwargs={'pk': recipe_1_s1.pk})
r = u1_s1.get(url)
assert r.status_code == 302
share = ShareLink.objects.filter(recipe=recipe_1_s1).first()
assert share
assert share_link_valid(recipe_1_s1, share.uuid)
url = reverse(
'view_recipe',
kwargs={'pk': recipe_1_s1.pk, 'share': share.uuid}
)
r = a_u.get(url)
assert r.status_code == 200
url = reverse(
'view_recipe',
kwargs={'pk': (recipe_1_s1.pk + 1), 'share': share.uuid}
)
r = a_u.get(url)
assert r.status_code == 404
url = reverse(
'view_recipe',
kwargs={'pk': recipe_1_s1.pk, 'share': uuid.uuid4()}
)
r = a_u.get(url)
assert r.status_code == 302

View File

@@ -133,9 +133,6 @@ urlpatterns = [
path('service-worker.js', (TemplateView.as_view(template_name="sw.js", content_type='application/javascript')), name='service_worker'),
path('manifest.json', views.web_manifest, name='web_manifest'),
re_path(r'^v3/.*', views.vue3, name='vue_3'),
path('', views.index, name='index'),
path('<path:resource>', views.index, name='tandoor_frontend'),
]
generic_models = (Recipe, RecipeImport, Storage, ConnectorConfig, RecipeBook, SyncLog, Sync, Comment, RecipeBookEntry, InviteLink, UserSpace, Space)
@@ -167,3 +164,10 @@ for m in vue_models:
if DEBUG:
urlpatterns.append(path('test/', views.test, name='view_test'))
urlpatterns.append(path('test2/', views.test2, name='view_test2'))
# catchall view for new frontend
urlpatterns += [
re_path(r'^v3/.*', views.vue3, name='vue_3'),
path('', views.index, name='index'),
path('<path:resource>', views.index, name='tandoor_frontend'),
]