Esempio n. 1
0
def test_invalid_attribute_key(app):
    app.config["METADATA_HEADERS"] = {"a": "a" * 257}
    with pytest.raises(ValueError) as e_info:
        publish.init_app(app)
    assert e_info.value.args == (
        "Metadata attribute exceeds key size limit of 256 bytes",
    )
Esempio n. 2
0
def test_missing_queue_path(app):
    del app.config["QUEUE_PATH"]
    with pytest.raises(TypeError) as e_info:
        publish.init_app(app)
    assert e_info.value.args == (
        "__init__() missing 1 required positional argument: 'path'",
    )
Esempio n. 3
0
async def test_endpoint(app, kwargs, method, mocker, uri_bytes):
    mocker.patch("ingestion_edge.publish.SQLiteAckQueue", dict)
    client = mocker.patch("ingestion_edge.publish.PublisherClient").return_value
    mocker.patch("ingestion_edge.publish.submit", lambda _, **kw: kw)
    app.config["ROUTE_TABLE"] = ROUTE_TABLE
    publish.init_app(app)
    responses = []
    request = Request(uri_bytes, {}, "1.1", method, None, app)
    await app.handle_request(request, lambda r: responses.append(r), None)
    assert responses == [
        dict(client=client, q={"path": ":memory:"}, metadata_headers={}, **kwargs)
    ]
Esempio n. 4
0
async def test_endpoint(app, kwargs, method, mocker, uri_bytes):
    Q = mocker.patch("ingestion_edge.publish.SQLiteAckQueue")
    client = mocker.patch(
        "ingestion_edge.publish.PublisherClient").return_value
    mocker.patch("ingestion_edge.publish.submit", lambda _, **kw: kw)
    app.config["ROUTE_TABLE"] = ROUTE_TABLE
    publish.init_app(app)
    responses = []
    request = Request(uri_bytes, {}, "1.1", method, None, app)
    await app.handle_request(request, lambda r: responses.append(r), None)
    assert responses == [
        dict(client=client, q=Q.return_value, metadata_headers={}, **kwargs)
    ]
    assert Q.mock_calls == [
        mock.call(path=':memory:', auto_resume=False),
        mock.call().resume_unack_tasks(),
        mock.call()._count()
    ]