- Sort Score
- Result 10 results
- Languages All
Results 151 - 160 of 1,379 for def2 (0.08 sec)
-
tests/test_union_body.py
price: int @app.post("/items/") def save_union_body(item: Union[OtherItem, Item]): return {"item": item} client = TestClient(app) def test_post_other_item(): response = client.post("/items/", json={"price": 100}) assert response.status_code == 200, response.text assert response.json() == {"item": {"price": 100}} def test_post_item():
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jul 07 17:12:13 UTC 2023 - 4.6K bytes - Viewed (0) -
tests/test_tutorial/test_bigger_applications/test_main_an_py39.py
from dirty_equals import IsDict from fastapi.testclient import TestClient from ...utils import needs_py39 @pytest.fixture(name="client") def get_client(): from docs_src.bigger_applications.app_an_py39.main import app client = TestClient(app) return client @needs_py39 def test_users_token_jessica(client: TestClient): response = client.get("/users?token=jessica") assert response.status_code == 200
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Thu Apr 18 19:40:57 UTC 2024 - 24.9K bytes - Viewed (0) -
tests/test_tutorial/test_security/test_tutorial005_py310.py
from dirty_equals import IsDict, IsOneOf from fastapi.testclient import TestClient from ...utils import needs_py310 @pytest.fixture(name="client") def get_client(): from docs_src.security.tutorial005_py310 import app client = TestClient(app) return client def get_access_token( *, username="johndoe", password="secret", scope=None, client: TestClient ): data = {"username": username, "password": password}
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Wed Mar 13 19:07:10 UTC 2024 - 16.3K bytes - Viewed (0) -
tests/test_tutorial/test_security/test_tutorial005_py39.py
from dirty_equals import IsDict, IsOneOf from fastapi.testclient import TestClient from ...utils import needs_py39 @pytest.fixture(name="client") def get_client(): from docs_src.security.tutorial005_py39 import app client = TestClient(app) return client def get_access_token( *, username="johndoe", password="secret", scope=None, client: TestClient ): data = {"username": username, "password": password}
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Wed Mar 13 19:07:10 UTC 2024 - 16.3K bytes - Viewed (0) -
tests/test_tutorial/test_security/test_tutorial005_an.py
def test_verify_password(): assert verify_password("secret", fake_users_db["johndoe"]["hashed_password"]) def test_get_password_hash(): assert get_password_hash("secretalice") def test_create_access_token(): access_token = create_access_token(data={"data": "foo"}) assert access_token def test_token_no_sub(): response = client.get(
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Wed Mar 13 19:07:10 UTC 2024 - 15.4K bytes - Viewed (0) -
tests/test_tutorial/test_dependencies/test_tutorial008d_an_py39.py
import pytest from fastapi.testclient import TestClient from ...utils import needs_py39 @pytest.fixture(name="client") def get_client(): from docs_src.dependencies.tutorial008d_an_py39 import app client = TestClient(app) return client @needs_py39 def test_get_no_item(client: TestClient): response = client.get("/items/foo") assert response.status_code == 404, response.text
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Feb 24 23:06:37 UTC 2024 - 1.3K bytes - Viewed (0) -
tests/test_security_api_key_query_description.py
class User(BaseModel): username: str def get_current_user(oauth_header: str = Security(api_key)): user = User(username=oauth_header) return user @app.get("/users/me") def read_current_user(current_user: User = Depends(get_current_user)): return current_user client = TestClient(app) def test_security_api_key(): response = client.get("/users/me?key=secret")
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 2K bytes - Viewed (0) -
tests/test_security_http_digest.py
from fastapi.testclient import TestClient app = FastAPI() security = HTTPDigest() @app.get("/users/me") def read_current_user(credentials: HTTPAuthorizationCredentials = Security(security)): return {"scheme": credentials.scheme, "credentials": credentials.credentials} client = TestClient(app) def test_security_http_digest(): response = client.get("/users/me", headers={"Authorization": "Digest foobar"})
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 2K bytes - Viewed (0) -
tests/test_security_oauth2_authorization_code_bearer.py
) @app.get("/items/") async def read_items(token: Optional[str] = Security(oauth2_scheme)): return {"token": token} client = TestClient(app) def test_no_token(): response = client.get("/items") assert response.status_code == 401, response.text assert response.json() == {"detail": "Not authenticated"} def test_incorrect_token():
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 2.3K bytes - Viewed (0) -
docs_src/background_tasks/tutorial002_an_py39.py
app = FastAPI() def write_log(message: str): with open("log.txt", mode="a") as log: log.write(message) def get_query(background_tasks: BackgroundTasks, q: Union[str, None] = None): if q: message = f"found query: {q}\n" background_tasks.add_task(write_log, message) return q @app.post("/send-notification/{email}") async def send_notification(
Registered: Sun Nov 03 07:19:11 UTC 2024 - Last Modified: Sat Mar 18 12:29:59 UTC 2023 - 696 bytes - Viewed (0)