mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2025-12-23 18:29:23 -05:00
added test to check for API pagination
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -80,7 +80,6 @@ data/
|
||||
/docker-compose.override.yml
|
||||
vue/node_modules
|
||||
/recipes/plugins
|
||||
.vscode/
|
||||
vetur.config.js
|
||||
cookbook/static/vue
|
||||
vue/webpack-stats.json
|
||||
|
||||
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@@ -24,7 +24,7 @@
|
||||
"console": "integratedTerminal",
|
||||
"env": {
|
||||
// coverage and pytest can't both be running at the same time
|
||||
"PYTEST_ADDOPTS": "--no-cov"
|
||||
"PYTEST_ADDOPTS": "--no-cov -n 0"
|
||||
},
|
||||
"django": true,
|
||||
"justMyCode": true
|
||||
|
||||
@@ -3,8 +3,8 @@ from django.contrib import auth
|
||||
from mock.mock import Mock
|
||||
|
||||
from cookbook.connectors.connector import Connector
|
||||
from cookbook.connectors.connector_manager import run_connectors, ActionType
|
||||
from cookbook.models import ShoppingListEntry, Food
|
||||
from cookbook.connectors.connector_manager import ActionType, run_connectors
|
||||
from cookbook.models import Food, ShoppingListEntry
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
@@ -13,7 +13,7 @@ def obj_1(space_1, u1_s1):
|
||||
return e
|
||||
|
||||
|
||||
@pytest.mark.timeout(10)
|
||||
@pytest.mark.timeout(10) # TODO this mark doesn't exist
|
||||
@pytest.mark.asyncio
|
||||
async def test_run_connectors(space_1, u1_s1, obj_1) -> None:
|
||||
connector_mock = Mock(spec=Connector)
|
||||
|
||||
19
cookbook/tests/other/test_schemas.py
Normal file
19
cookbook/tests/other/test_schemas.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import pytest
|
||||
|
||||
from cookbook.urls import router
|
||||
|
||||
exclude_endpoints = []
|
||||
|
||||
|
||||
@pytest.mark.parametrize("route", router.registry)
|
||||
def test_pagination_exists(route):
|
||||
# route[0] = name
|
||||
# route[1] = ViewSet class
|
||||
# route[2] = reverse name
|
||||
|
||||
assert ('get' not in route[1].http_method_names
|
||||
or 'get' in route[1].http_method_names and hasattr(route[1], 'pagination_class') and route[1].pagination_class is not None), f"API {route[0]} is not paginated."
|
||||
|
||||
|
||||
def test_schema_completeness():
|
||||
pass
|
||||
@@ -631,7 +631,7 @@ class FoodViewSet(TreeMixin):
|
||||
food.properties_food_unit = Unit.objects.get_or_create(
|
||||
base_unit__iexact='g',
|
||||
space=self.request.space,
|
||||
defaults={ 'name': 'g', 'base_unit': 'g', 'space': self.request.space}
|
||||
defaults={'name': 'g', 'base_unit': 'g', 'space': self.request.space}
|
||||
)[0]
|
||||
|
||||
food.save()
|
||||
@@ -776,6 +776,7 @@ class MealPlanViewSet(viewsets.ModelViewSet):
|
||||
|
||||
|
||||
class AutoPlanViewSet(viewsets.ViewSet):
|
||||
http_method_names = ['post', 'options']
|
||||
|
||||
def create(self, request):
|
||||
serializer = AutoMealPlanSerializer(data=request.data)
|
||||
@@ -1693,6 +1694,7 @@ def share_link(request, pk):
|
||||
return JsonResponse({'error': 'sharing_disabled'}, status=403)
|
||||
|
||||
|
||||
# TODO does this need to be seperate from the Cooklog API?
|
||||
@group_required('user')
|
||||
@ajax_request
|
||||
def log_cooking(request, recipe_id):
|
||||
|
||||
Reference in New Issue
Block a user