示例#1
0
def test_create_logging(monkeypatch):
    bound_logger = pretend.stub()
    logger = pretend.stub(
        bind=pretend.call_recorder(lambda **kw: bound_logger))
    monkeypatch.setattr(wlogging, "request_logger", logger)

    request = pretend.stub(id="request id")

    assert wlogging._create_logger(request) is bound_logger
    assert logger.bind.calls == [pretend.call(**{"request.id": "request id"})]
示例#2
0
def test_create_logging(monkeypatch):
    bound_logger = pretend.stub()
    logger = pretend.stub(
        bind=pretend.call_recorder(lambda **kw: bound_logger),
    )
    monkeypatch.setattr(wlogging, "request_logger", logger)

    request = pretend.stub(id="request id")

    assert wlogging._create_logger(request) is bound_logger
    assert logger.bind.calls == [pretend.call(**{"request.id": "request id"})]
示例#3
0
def test_create_logging(monkeypatch):
    bound_logger = pretend.stub()
    logger = pretend.stub(
        bind=pretend.call_recorder(lambda **kw: bound_logger), )
    get_logger = pretend.call_recorder(lambda name: logger)
    monkeypatch.setattr(structlog, "get_logger", get_logger)

    request = pretend.stub(id="request id")

    assert wlogging._create_logger(request) is bound_logger
    assert get_logger.calls == [pretend.call("warehouse.request")]
    assert logger.bind.calls == [pretend.call(**{"request.id": "request id"})]
示例#4
0
def test_create_logging(monkeypatch):
    bound_logger = pretend.stub()
    logger = pretend.stub(
        bind=pretend.call_recorder(lambda **kw: bound_logger),
    )
    get_logger = pretend.call_recorder(lambda name: logger)
    monkeypatch.setattr(structlog, "get_logger", get_logger)

    request = pretend.stub(id="request id")

    assert wlogging._create_logger(request) is bound_logger
    assert get_logger.calls == [pretend.call("warehouse.request")]
    assert logger.bind.calls == [pretend.call(**{"request.id": "request id"})]