forked from snok/drf-openapi-tester
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from maticardenas/41-import-error-for-projects…
…-without-ninja fix: making import of ninja optional
- Loading branch information
Showing
6 changed files
with
71 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,41 +3,35 @@ | |
|
||
import pytest | ||
|
||
from openapi_tester import OpenAPIClient, SchemaTester | ||
from openapi_tester import SchemaTester | ||
from openapi_tester.clients import OpenAPINinjaClient | ||
from openapi_tester.exceptions import UndocumentedSchemaSectionError | ||
from test_project.api.ninja.api import router | ||
from tests.utils import TEST_ROOT | ||
|
||
if TYPE_CHECKING: | ||
from pathlib import Path | ||
|
||
|
||
@pytest.fixture | ||
def users_ninja_api_schema() -> "Path": | ||
return TEST_ROOT / "schemas" / "users_django_api_schema.yaml" | ||
|
||
|
||
@pytest.fixture | ||
def client(users_ninja_api_schema: "Path") -> OpenAPIClient: | ||
def client(users_ninja_api_schema: "Path") -> OpenAPINinjaClient: | ||
return OpenAPINinjaClient( | ||
router_or_app=router, | ||
path_prefix="/ninja_api/users", | ||
schema_tester=SchemaTester(schema_file_path=str(users_ninja_api_schema)), | ||
) | ||
|
||
|
||
def test_get_users(client: OpenAPIClient): | ||
def test_get_users(client: OpenAPINinjaClient): | ||
response = client.get("/") | ||
assert response.status_code == 200 | ||
|
||
|
||
def test_get_user(client: OpenAPIClient): | ||
def test_get_user(client: OpenAPINinjaClient): | ||
response = client.get("/1") | ||
assert response.status_code == 200 | ||
|
||
|
||
def test_create_user(client: OpenAPIClient): | ||
def test_create_user(client: OpenAPINinjaClient): | ||
payload = { | ||
"name": "John Doe", | ||
"email": "[email protected]", | ||
|
@@ -52,7 +46,7 @@ def test_create_user(client: OpenAPIClient): | |
assert response.status_code == 201 | ||
|
||
|
||
def test_update_user(client: OpenAPIClient): | ||
def test_update_user(client: OpenAPINinjaClient): | ||
payload = { | ||
"name": "John Doe", | ||
"email": "[email protected]", | ||
|
@@ -67,14 +61,14 @@ def test_update_user(client: OpenAPIClient): | |
assert response.status_code == 200 | ||
|
||
|
||
def test_delete_user(client: OpenAPIClient): | ||
def test_delete_user(client: OpenAPINinjaClient): | ||
response = client.delete( | ||
path="/1", | ||
) | ||
assert response.status_code == 204 | ||
|
||
|
||
def test_patch_user_undocumented_path(client: OpenAPIClient): | ||
def test_patch_user_undocumented_path(client: OpenAPINinjaClient): | ||
payload = { | ||
"name": "John Doe", | ||
} | ||
|