예제 #1
0
async def test_speccurrent(aiohttp_client: TestClient) -> None:
    """Test GET /app-name/"""
    app = create_app()
    name = app["safir/config"].name
    client = await aiohttp_client(app)
    response = await client.get(f"/{name}/spec_current")
    assert response.status == 200
예제 #2
0
async def test_imevents(aiohttp_client: TestClient) -> None:
    """Test GET /app-name/"""
    app = create_app()
    name = app["safir/config"].name
    client = await aiohttp_client(app)
    response = await client.get(f"/{name}/imevents/2021-03-23/327")
    assert response.status == 200
예제 #3
0
async def test_get_index_num(aiohttp_client: TestClient) -> None:
    """Test GET /app-name/"""
    app = create_app()
    name = app["safir/config"].name
    client = await aiohttp_client(app)

    response = await client.get(f"/{name}/?num=10")
    assert response.status == 200
예제 #4
0
async def test_get_index_num_fail(aiohttp_client: TestClient) -> None:
    """Test GET /app-name/"""
    app = create_app()
    name = app["safir/config"].name
    client = await aiohttp_client(app)

    response = await client.get(f"/{name}/?num=hello")
    # Expect this to fail since "hello" can't be coerced to an int
    assert response.status == 500
예제 #5
0
async def test_get_index(aiohttp_client: TestClient) -> None:
    """Test GET /"""
    app = create_app()
    client = await aiohttp_client(app)

    response = await client.get("/")
    assert response.status == 200
    data = await response.json()
    assert data["name"] == app["safir/config"].name
    assert isinstance(data["version"], str)
    assert isinstance(data["description"], str)
    assert isinstance(data["repository_url"], str)
    assert isinstance(data["documentation_url"], str)
예제 #6
0
def run(ctx: click.Context, port: int) -> None:
    """Run the application (for production)."""
    app = create_app()
    run_app(app, port=port)