From d8aa737412d5d6b76da854f8c7794737cc88467c Mon Sep 17 00:00:00 2001 From: georgepsarakis Date: Mon, 9 Dec 2019 22:19:12 +0200 Subject: [PATCH] Test logger module --- chronicle/logger.py | 6 +++--- tests/test_logger.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/chronicle/logger.py b/chronicle/logger.py index 55862e4..d404067 100644 --- a/chronicle/logger.py +++ b/chronicle/logger.py @@ -1,16 +1,16 @@ import os -_MAIN_PROCESS_IDENTIFIER = "COORDINATOR" +MAIN_PROCESS_IDENTIFIER = "COORDINATOR" def generate(message, task_id=None, pid=None, stream=None, **kwargs): pid = pid or os.getpid() - task_id = task_id or _MAIN_PROCESS_IDENTIFIER + task_id = task_id or MAIN_PROCESS_IDENTIFIER entry = { "message": str(message), "task_id": task_id, - "pid": str(pid), + "pid": pid, "stream": stream, } entry.update( diff --git a/tests/test_logger.py b/tests/test_logger.py index e69de29..a94b504 100644 --- a/tests/test_logger.py +++ b/tests/test_logger.py @@ -0,0 +1,13 @@ +import os +from chronicle import logger + + +class TestLogger: + def test_generate(self): + assert logger.generate("test message") == \ + { + "message": "test message", + "task_id": logger.MAIN_PROCESS_IDENTIFIER, + "pid": os.getpid(), + "stream": None, + }