diff --git a/cookbook/tests/edits/test_edits_recipe.py b/cookbook/tests/edits/test_edits_recipe.py deleted file mode 100644 index 6c014e79b..000000000 --- a/cookbook/tests/edits/test_edits_recipe.py +++ /dev/null @@ -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 diff --git a/cookbook/tests/views/test_views_general.py b/cookbook/tests/views/test_views_general.py index b9e132f38..2017323ed 100644 --- a/cookbook/tests/views/test_views_general.py +++ b/cookbook/tests/views/test_views_general.py @@ -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", [ diff --git a/cookbook/tests/views/test_views_recipe_share.py b/cookbook/tests/views/test_views_recipe_share.py deleted file mode 100644 index 86ee680da..000000000 --- a/cookbook/tests/views/test_views_recipe_share.py +++ /dev/null @@ -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 diff --git a/cookbook/urls.py b/cookbook/urls.py index 280cad4ca..4ea0e2f3a 100644 --- a/cookbook/urls.py +++ b/cookbook/urls.py @@ -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('', 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('', views.index, name='tandoor_frontend'), +] \ No newline at end of file