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"})]
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"})]
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"})]