Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 467 for test_0 (0.23 sec)

  1. docs_src/app_testing/app_b/test_main.py

    from .main import app
    
    client = TestClient(app)
    
    
    def test_read_item():
        response = client.get("/items/foo", headers={"X-Token": "coneofsilence"})
        assert response.status_code == 200
        assert response.json() == {
            "id": "foo",
            "title": "Foo",
            "description": "There goes my hero",
        }
    
    
    def test_read_item_bad_token():
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Wed Mar 13 19:07:10 GMT 2024
    - 1.8K bytes
    - Viewed (0)
  2. docs_src/async_tests/test_main.py

    import pytest
    from httpx import AsyncClient
    
    from .main import app
    
    
    @pytest.mark.anyio
    async def test_root():
        async with AsyncClient(app=app, base_url="http://test") as ac:
            response = await ac.get("/")
        assert response.status_code == 200
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Wed Oct 06 15:32:11 GMT 2021
    - 306 bytes
    - Viewed (0)
  3. tests/test_application.py

            ("/nonexistent", 404, {"detail": "Not Found"}),
        ],
    )
    def test_get_path(path, expected_status, expected_response):
        response = client.get(path)
        assert response.status_code == expected_status
        assert response.json() == expected_response
    
    
    def test_swagger_ui():
        response = client.get("/docs")
        assert response.status_code == 200, response.text
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 21:56:59 GMT 2024
    - 52.2K bytes
    - Viewed (0)
  4. tests/test_tuples.py

        return values
    
    
    client = TestClient(app)
    
    
    def test_model_with_tuple_valid():
        data = {"items": [["foo", "bar"], ["baz", "whatelse"]]}
        response = client.post("/model-with-tuple/", json=data)
        assert response.status_code == 200, response.text
        assert response.json() == data
    
    
    def test_model_with_tuple_invalid():
        data = {"items": [["foo", "bar"], ["baz", "whatelse", "too", "much"]]}
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 11.8K bytes
    - Viewed (0)
  5. tests/test_tutorial/test_background_tasks/test_tutorial002.py

    import os
    from pathlib import Path
    
    from fastapi.testclient import TestClient
    
    from docs_src.background_tasks.tutorial002 import app
    
    client = TestClient(app)
    
    
    def test():
        log = Path("log.txt")
        if log.is_file():
            os.remove(log)  # pragma: no cover
        response = client.post("/send-notification/******@****.***?q=some-query")
        assert response.status_code == 200, response.text
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Jul 09 18:06:12 GMT 2020
    - 568 bytes
    - Viewed (0)
  6. tests/test_tutorial/test_behind_a_proxy/test_tutorial003.py

    from fastapi.testclient import TestClient
    
    from docs_src.behind_a_proxy.tutorial003 import app
    
    client = TestClient(app)
    
    
    def test_main():
        response = client.get("/app")
        assert response.status_code == 200
        assert response.json() == {"message": "Hello World", "root_path": "/api/v1"}
    
    
    def test_openapi_schema():
        response = client.get("/openapi.json")
        assert response.status_code == 200
        assert response.json() == {
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 1.6K bytes
    - Viewed (0)
  7. tests/test_tutorial/test_advanced_middleware/test_tutorial001.py

    from fastapi.testclient import TestClient
    
    from docs_src.advanced_middleware.tutorial001 import app
    
    
    def test_middleware():
        client = TestClient(app, base_url="https://testserver")
        response = client.get("/")
        assert response.status_code == 200, response.text
    
        client = TestClient(app)
        response = client.get("/", follow_redirects=False)
        assert response.status_code == 307, response.text
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sun Nov 13 14:26:09 GMT 2022
    - 474 bytes
    - Viewed (0)
  8. tests/test_tutorial/test_advanced_middleware/test_tutorial003.py

    from docs_src.advanced_middleware.tutorial003 import app
    
    
    @app.get("/large")
    async def large():
        return PlainTextResponse("x" * 4000, status_code=200)
    
    
    client = TestClient(app)
    
    
    def test_middleware():
        response = client.get("/large", headers={"accept-encoding": "gzip"})
        assert response.status_code == 200, response.text
        assert response.text == "x" * 4000
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Jul 09 18:06:12 GMT 2020
    - 665 bytes
    - Viewed (0)
  9. tests/test_tutorial/test_body_multiple_params/test_tutorial003.py

    from fastapi.testclient import TestClient
    
    
    @pytest.fixture(name="client")
    def get_client():
        from docs_src.body_multiple_params.tutorial003 import app
    
        client = TestClient(app)
        return client
    
    
    def test_post_body_valid(client: TestClient):
        response = client.put(
            "/items/5",
            json={
                "importance": 2,
                "item": {"name": "Foo", "price": 50.5},
                "user": {"username": "Dave"},
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 9.4K bytes
    - Viewed (0)
  10. tests/test_tutorial/test_configure_swagger_ui/test_tutorial001.py

    from fastapi.testclient import TestClient
    
    from docs_src.configure_swagger_ui.tutorial001 import app
    
    client = TestClient(app)
    
    
    def test_swagger_ui():
        response = client.get("/docs")
        assert response.status_code == 200, response.text
        assert (
            '"syntaxHighlight": false' in response.text
        ), "syntaxHighlight should be included and converted to JSON"
        assert (
            '"dom_id": "#swagger-ui"' in response.text
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Aug 19 19:54:04 GMT 2023
    - 1.4K bytes
    - Viewed (0)
Back to top