Ejemplo n.º 1
0
def test_index(monkeypatch):
    response = pretend.stub(status_code=200, headers=Headers())
    render = pretend.call_recorder(lambda *a, **k: response)
    monkeypatch.setattr(simple, "render_response", render)

    all_projects = ["bar", "foo"]

    app = pretend.stub(
        config=pretend.stub(
            cache=pretend.stub(browser=False, varnish=False),
        ),
        models=pretend.stub(
            packaging=pretend.stub(
                all_projects=pretend.call_recorder(lambda: all_projects),
                get_last_serial=pretend.call_recorder(lambda: 9999),
            ),
        ),
    )
    request = pretend.stub()

    resp = simple.index(app, request)

    assert resp is response
    assert resp.headers["X-PyPI-Last-Serial"] == "9999"
    assert resp.headers["Surrogate-Key"] == "simple-index"

    assert render.calls == [
        pretend.call(
            app, request,
            "legacy/simple/index.html",
            projects=all_projects,
        ),
    ]
Ejemplo n.º 2
0
def test_index(monkeypatch):
    response = pretend.stub(status_code=200, headers=Headers())
    render = pretend.call_recorder(lambda *a, **k: response)
    monkeypatch.setattr(simple, "render_response", render)

    all_projects = ["bar", "foo"]

    app = pretend.stub(
        config=pretend.stub(cache=pretend.stub(browser=False,
                                               varnish=False), ),
        models=pretend.stub(packaging=pretend.stub(
            all_projects=pretend.call_recorder(lambda: all_projects),
            get_last_serial=pretend.call_recorder(lambda: 9999),
        ), ),
    )
    request = pretend.stub()

    resp = simple.index(app, request)

    assert resp is response
    assert resp.headers["X-PyPI-Last-Serial"] == "9999"
    assert resp.headers["Surrogate-Key"] == "simple-index"

    assert render.calls == [
        pretend.call(
            app,
            request,
            "legacy/simple/index.html",
            projects=all_projects,
        ),
    ]
Ejemplo n.º 3
0
def test_index(app):
    all_projects = ["bar", "foo"]

    app.db = pretend.stub(
        packaging=pretend.stub(
            all_projects=pretend.call_recorder(lambda: all_projects),
            get_last_serial=pretend.call_recorder(lambda: 9999),
        ),
    )

    request = pretend.stub()
    resp = simple.index(app, request)

    assert resp.headers["X-PyPI-Last-Serial"] == "9999"
    assert resp.response.template.name == "legacy/simple/index.html"
    assert resp.response.context == {
        "projects": ["bar", "foo"],
    }