Skip to content
This repository has been archived by the owner on Nov 19, 2023. It is now read-only.

Commit

Permalink
renamed demo to test_project and moved schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
Na'aman Hirschfeld authored and Na'aman Hirschfeld committed Jan 16, 2021
1 parent 876820c commit 0f4d6ad
Show file tree
Hide file tree
Showing 78 changed files with 43 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
demo/static/*
test_project/static/*

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ A full example of the ``OPENAPI_TESTER`` settings might look like this:
OPENAPI_TESTER = {
'SCHEMA_LOADER': StaticSchemaLoader,
'PATH': 'demo/openapi-schema.yml',
'PATH': 'test_project/openapi-schema.yml',
'CASE_TESTER': is_camel_case,
'CASE_PASSLIST': ['IP', 'DHCP'],
}
Expand Down
2 changes: 1 addition & 1 deletion manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demo.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_project.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[pytest]
DJANGO_SETTINGS_MODULE = demo.settings
DJANGO_SETTINGS_MODULE = test_project.settings
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from drf_yasg.openapi import TYPE_ARRAY, TYPE_OBJECT, Schema
from drf_yasg.utils import swagger_auto_schema

from demo.api.serializers import VehicleSerializer
from demo.api.swagger.responses import generic_error_response, get_cars_200_response, get_trucks_200_response
from demo.api.swagger.schemas import generic_string_schema
from test_project.api.serializers import VehicleSerializer
from test_project.api.swagger.responses import generic_error_response, get_cars_200_response, get_trucks_200_response
from test_project.api.swagger.schemas import generic_string_schema


def get_cars_auto_schema():
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from rest_framework.status import HTTP_200_OK, HTTP_204_NO_CONTENT
from rest_framework.views import APIView

from demo.api.swagger.auto_schemas import animals_auto_schema
from test_project.api.swagger.auto_schemas import animals_auto_schema


class Animals(APIView):
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion demo/api/views/i18n.py → test_project/api/views/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from rest_framework.status import HTTP_200_OK
from rest_framework.views import APIView

from demo.api.swagger.auto_schemas import languages_auto_schema
from test_project.api.swagger.auto_schemas import languages_auto_schema


class Languages(APIView):
Expand Down
4 changes: 2 additions & 2 deletions demo/api/views/items.py → test_project/api/views/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from rest_framework.response import Response
from rest_framework.views import APIView

from demo.api.serializers import ItemSerializer
from demo.api.swagger.auto_schemas import post_item_auto_schema
from test_project.api.serializers import ItemSerializer
from test_project.api.swagger.auto_schemas import post_item_auto_schema


class Items(APIView):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from rest_framework.response import Response
from rest_framework.views import APIView

from demo.api.swagger.auto_schemas import VehicleSerializer, post_vehicle_auto_schema
from test_project.api.swagger.auto_schemas import VehicleSerializer, post_vehicle_auto_schema


class Vehicles(APIView):
Expand Down
4 changes: 2 additions & 2 deletions demo/asgi.py → test_project/asgi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
ASGI config for demo project.
ASGI config for test_project.
It exposes the ASGI callable as a module-level variable named ``application``.
Expand All @@ -11,6 +11,6 @@

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demo.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_project.settings')

application = get_asgi_application()
12 changes: 6 additions & 6 deletions demo/settings.py → test_project/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Django settings for demo project.
Django settings for test project.
Generated by 'django-admin startproject' using Django 3.1.
Expand Down Expand Up @@ -58,7 +58,7 @@
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'demo.urls'
ROOT_URLCONF = 'test_project.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
Expand All @@ -74,7 +74,7 @@
},
},
]
WSGI_APPLICATION = 'demo.wsgi.application'
WSGI_APPLICATION = 'test_project.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
Expand All @@ -99,12 +99,12 @@
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/demo/static/'
STATIC_URL = '/test_project/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

SWAGGER_SETTINGS = {
'DEFAULT_MODEL_RENDERING': 'example',
'DEFAULT_INFO': 'demo.urls.swagger_info',
'DEFAULT_INFO': 'test_project.urls.swagger_info',
}

REST_FRAMEWORK = {
Expand Down Expand Up @@ -134,7 +134,7 @@
}
OPENAPI_TESTER = {
'SCHEMA_LOADER': DrfYasgSchemaLoader,
'PATH': 'demo/openapi-schema.yml',
'PATH': 'test_project/openapi-schema.yml',
'CASE_TESTER': is_camel_case,
'CASE_PASSLIST': [],
'PARAMETERIZED_I18N_NAME': '',
Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions demo/urls.py → test_project/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
from drf_yasg.views import get_schema_view
from rest_framework import permissions

from demo import views
from demo.api.views.animals import Animals
from demo.api.views.cars import BadCars, GoodCars
from demo.api.views.exempt_endpoint import Exempt
from demo.api.views.i18n import Languages
from demo.api.views.items import Items
from demo.api.views.snake_cased_response import SnakeCasedResponse
from demo.api.views.trucks import BadTrucks, GoodTrucks
from demo.api.views.vehicles import Vehicles
from test_project import views
from test_project.api.views.animals import Animals
from test_project.api.views.cars import BadCars, GoodCars
from test_project.api.views.exempt_endpoint import Exempt
from test_project.api.views.i18n import Languages
from test_project.api.views.items import Items
from test_project.api.views.snake_cased_response import SnakeCasedResponse
from test_project.api.views.trucks import BadTrucks, GoodTrucks
from test_project.api.views.vehicles import Vehicles


class IsValidVehicleType(StringConverter):
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions demo/wsgi.py → test_project/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
WSGI config for demo project.
WSGI config for test_project.
It exposes the WSGI callable as a module-level variable named ``application``.
Expand All @@ -11,6 +11,6 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demo.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_project.settings')

application = get_wsgi_application()
10 changes: 6 additions & 4 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from demo import settings
from pathlib import Path

yml_path = f'{settings.BASE_DIR}/static_schemas/openapi-schema.yml'
yml_split_path = f'{settings.BASE_DIR}/static_schemas/openapi-schema-split.yaml'
json_path = f'{settings.BASE_DIR}/static_schemas/openapi-schema.json'
current_path = Path(__file__).resolve(strict=True).parent

yml_path = f'{current_path}/test_schemas/openapi-schema.yml'
yml_split_path = f'{current_path}/test_schemas/openapi-schema-split.yaml'
json_path = f'{current_path}/test_schemas/openapi-schema.json'
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

def test_valid_settings() -> None:
"""
Assert that the default settings in the demo project pass without errors.
Assert that the default settings in the test_project pass without errors.
"""
OpenAPITesterSettings().validate()

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

def test_static_schema_loader_validation():
"""
Verify that validation runs successfully for the demo project.
Verify that validation runs successfully for the test_project.
"""
with override_settings(OPENAPI_TESTER={'PATH': yml_path, 'SCHEMA_LOADER': StaticSchemaLoader}):
settings = OpenAPITesterSettings()
Expand All @@ -18,7 +18,7 @@ def test_static_schema_loader_validation():

def test_missing_path():
"""
Verify that validation runs successfully for the demo project.
Verify that validation runs successfully for the test_project.
"""
with override_settings(OPENAPI_TESTER={'SCHEMA_LOADER': StaticSchemaLoader}):
with pytest.raises(
Expand All @@ -30,7 +30,7 @@ def test_missing_path():

def test_bad_path_type():
"""
Verify that validation runs successfully for the demo project.
Verify that validation runs successfully for the test_project.
"""
with override_settings(OPENAPI_TESTER={'PATH': 2, 'SCHEMA_LOADER': StaticSchemaLoader}):
with pytest.raises(
Expand Down
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from openapi_tester.loaders import StaticSchemaLoader
from openapi_tester.testing import OpenAPITestCase
from tests import yml_path
from tests.test_testers.test_validate_response import BAD_TEST_DATA, GOOD_TEST_DATA
from tests.validate_response_tests import BAD_TEST_DATA, GOOD_TEST_DATA


def test_django_test_case(client, monkeypatch) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from openapi_tester.loaders import StaticSchemaLoader
from openapi_tester.testing import validate_response
from tests import yml_path
from tests.test_testers.test_validate_response import GOOD_TEST_DATA, I18N_DATA
from tests.validate_response_tests import GOOD_TEST_DATA, I18N_DATA


def test_endpoints_static_schema(client, monkeypatch) -> None:
Expand Down

0 comments on commit 0f4d6ad

Please sign in to comment.