committed by
GitHub
6 changed files with 4 additions and 25 deletions
@ -5,8 +5,6 @@ from unittest.mock import MagicMock |
|||
import pytest |
|||
from fastapi.testclient import TestClient |
|||
|
|||
from ...utils import needs_py37 |
|||
|
|||
openapi_schema = { |
|||
"openapi": "3.0.2", |
|||
"info": {"title": "FastAPI", "version": "0.1.0"}, |
|||
@ -340,14 +338,12 @@ def client(): |
|||
test_db.unlink() |
|||
|
|||
|
|||
@needs_py37 |
|||
def test_openapi_schema(client): |
|||
response = client.get("/openapi.json") |
|||
assert response.status_code == 200, response.text |
|||
assert response.json() == openapi_schema |
|||
|
|||
|
|||
@needs_py37 |
|||
def test_create_user(client): |
|||
test_user = {"email": "[email protected]", "password": "secret"} |
|||
response = client.post("/users/", json=test_user) |
|||
@ -359,7 +355,6 @@ def test_create_user(client): |
|||
assert response.status_code == 400, response.text |
|||
|
|||
|
|||
@needs_py37 |
|||
def test_get_user(client): |
|||
response = client.get("/users/1") |
|||
assert response.status_code == 200, response.text |
|||
@ -368,13 +363,11 @@ def test_get_user(client): |
|||
assert "id" in data |
|||
|
|||
|
|||
@needs_py37 |
|||
def test_inexistent_user(client): |
|||
response = client.get("/users/999") |
|||
assert response.status_code == 404, response.text |
|||
|
|||
|
|||
@needs_py37 |
|||
def test_get_users(client): |
|||
response = client.get("/users/") |
|||
assert response.status_code == 200, response.text |
|||
@ -386,7 +379,6 @@ def test_get_users(client): |
|||
time.sleep = MagicMock() |
|||
|
|||
|
|||
@needs_py37 |
|||
def test_get_slowusers(client): |
|||
response = client.get("/slowusers/") |
|||
assert response.status_code == 200, response.text |
|||
@ -395,7 +387,6 @@ def test_get_slowusers(client): |
|||
assert "id" in data[0] |
|||
|
|||
|
|||
@needs_py37 |
|||
def test_create_item(client): |
|||
item = {"title": "Foo", "description": "Something that fights"} |
|||
response = client.post("/users/1/items/", json=item) |
|||
@ -419,7 +410,6 @@ def test_create_item(client): |
|||
assert item_to_check["description"] == item["description"] |
|||
|
|||
|
|||
@needs_py37 |
|||
def test_read_items(client): |
|||
response = client.get("/items/") |
|||
assert response.status_code == 200, response.text |
|||
|
Loading…
Reference in new issue