Browse Source

📸 Update snapshots

pull/14864/head
Sebastián Ramírez 5 months ago
parent
commit
1f51fa350d
  1. 5
      tests/test_additional_responses_response_class.py
  2. 5
      tests/test_tutorial/test_behind_a_proxy/test_tutorial001.py
  3. 5
      tests/test_tutorial/test_behind_a_proxy/test_tutorial002.py
  4. 5
      tests/test_tutorial/test_extending_openapi/test_tutorial001.py

5
tests/test_additional_responses_response_class.py

@ -1,6 +1,7 @@
from fastapi import FastAPI from fastapi import FastAPI
from fastapi.responses import JSONResponse from fastapi.responses import JSONResponse
from fastapi.testclient import TestClient from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from pydantic import BaseModel from pydantic import BaseModel
app = FastAPI() app = FastAPI()
@ -39,7 +40,8 @@ client = TestClient(app)
def test_openapi_schema(): def test_openapi_schema():
response = client.get("/openapi.json") response = client.get("/openapi.json")
assert response.status_code == 200, response.text assert response.status_code == 200, response.text
assert response.json() == { assert response.json() == snapshot(
{
"openapi": "3.1.0", "openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"}, "info": {"title": "FastAPI", "version": "0.1.0"},
"paths": { "paths": {
@ -112,3 +114,4 @@ def test_openapi_schema():
} }
}, },
} }
)

5
tests/test_tutorial/test_behind_a_proxy/test_tutorial001.py

@ -1,4 +1,5 @@
from fastapi.testclient import TestClient from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from docs_src.behind_a_proxy.tutorial001_py39 import app from docs_src.behind_a_proxy.tutorial001_py39 import app
@ -14,7 +15,8 @@ def test_main():
def test_openapi(): def test_openapi():
response = client.get("/openapi.json") response = client.get("/openapi.json")
assert response.status_code == 200 assert response.status_code == 200
assert response.json() == { assert response.json() == snapshot(
{
"openapi": "3.1.0", "openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"}, "info": {"title": "FastAPI", "version": "0.1.0"},
"paths": { "paths": {
@ -33,3 +35,4 @@ def test_openapi():
}, },
"servers": [{"url": "/api/v1"}], "servers": [{"url": "/api/v1"}],
} }
)

5
tests/test_tutorial/test_behind_a_proxy/test_tutorial002.py

@ -1,4 +1,5 @@
from fastapi.testclient import TestClient from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from docs_src.behind_a_proxy.tutorial002_py39 import app from docs_src.behind_a_proxy.tutorial002_py39 import app
@ -14,7 +15,8 @@ def test_main():
def test_openapi(): def test_openapi():
response = client.get("/openapi.json") response = client.get("/openapi.json")
assert response.status_code == 200 assert response.status_code == 200
assert response.json() == { assert response.json() == snapshot(
{
"openapi": "3.1.0", "openapi": "3.1.0",
"info": {"title": "FastAPI", "version": "0.1.0"}, "info": {"title": "FastAPI", "version": "0.1.0"},
"paths": { "paths": {
@ -33,3 +35,4 @@ def test_openapi():
}, },
"servers": [{"url": "/api/v1"}], "servers": [{"url": "/api/v1"}],
} }
)

5
tests/test_tutorial/test_extending_openapi/test_tutorial001.py

@ -1,4 +1,5 @@
from fastapi.testclient import TestClient from fastapi.testclient import TestClient
from inline_snapshot import snapshot
from docs_src.extending_openapi.tutorial001_py39 import app from docs_src.extending_openapi.tutorial001_py39 import app
@ -14,7 +15,8 @@ def test():
def test_openapi_schema(): def test_openapi_schema():
response = client.get("/openapi.json") response = client.get("/openapi.json")
assert response.status_code == 200, response.text assert response.status_code == 200, response.text
assert response.json() == { assert response.json() == snapshot(
{
"openapi": "3.1.0", "openapi": "3.1.0",
"info": { "info": {
"title": "Custom title", "title": "Custom title",
@ -40,6 +42,7 @@ def test_openapi_schema():
} }
}, },
} }
)
openapi_schema = response.json() openapi_schema = response.json()
# Request again to test the custom cache # Request again to test the custom cache
response = client.get("/openapi.json") response = client.get("/openapi.json")

Loading…
Cancel
Save