Skip to content

Instantly share code, notes, and snippets.

@SyureNyanko
Created June 8, 2021 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SyureNyanko/2b17440dc996c2381cc7ee28693ea227 to your computer and use it in GitHub Desktop.
Save SyureNyanko/2b17440dc996c2381cc7ee28693ea227 to your computer and use it in GitHub Desktop.
from fastapi.testclient import TestClient
from main import app
client = TestClient(app)
def test_user_main():
test1 = {
"id": 1,
"name": "natsumi",
}
response = client.post("/user/", json=test1)
assert response.status_code == 200
def test_user_422():
test1 = {
"id": "string", # string, not int
"name": "natsumi",
}
response = client.post("/user/", json=test1)
assert response.status_code == 422
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment