diff --git a/.gitignore b/.gitignore index 7038b6553..b9876918f 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.vscode/launch.json b/.vscode/launch.json index a824f6dcc..9bd8037fa 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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 diff --git a/cookbook/tests/other/test_connector_manager.py b/cookbook/tests/other/test_connector_manager.py index 81916bf31..d7243f9af 100644 --- a/cookbook/tests/other/test_connector_manager.py +++ b/cookbook/tests/other/test_connector_manager.py @@ -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) diff --git a/cookbook/tests/other/test_schemas.py b/cookbook/tests/other/test_schemas.py new file mode 100644 index 000000000..7dc922ae7 --- /dev/null +++ b/cookbook/tests/other/test_schemas.py @@ -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 diff --git a/cookbook/views/api.py b/cookbook/views/api.py index cc4db3894..c766d483c 100644 --- a/cookbook/views/api.py +++ b/cookbook/views/api.py @@ -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):