From: Ismaƫl Bouya Date: Fri, 20 Apr 2018 18:07:03 +0000 (+0200) Subject: Store duration in http requests X-Git-Tag: v1.3~1^2^2~3 X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git;a=commitdiff_plain;h=9fe90554ff1c8c7aea9e1e1e210419a845579edd Store duration in http requests --- diff --git a/store.py b/store.py index 45a5233..0c018e0 100644 --- a/store.py +++ b/store.py @@ -211,6 +211,7 @@ class ReportStore: "body": body, "headers": headers, "status": response.status_code, + "duration": response.elapsed.total_seconds(), "response": None, "response_same_as": self.last_http["date"] }) @@ -222,6 +223,7 @@ class ReportStore: "body": body, "headers": headers, "status": response.status_code, + "duration": response.elapsed.total_seconds(), "response": response.text, "response_same_as": None, }) diff --git a/tests/test_store.py b/tests/test_store.py index 4232fc3..e281adb 100644 --- a/tests/test_store.py +++ b/tests/test_store.py @@ -830,6 +830,7 @@ class ReportStoreTest(WebMockTestCase): response = mock.Mock() response.status_code = 200 response.text = "Hey" + response.elapsed.total_seconds.return_value = 120 report_store.log_http_request("method", "url", "body", "headers", response) @@ -840,6 +841,7 @@ class ReportStoreTest(WebMockTestCase): 'body': 'body', 'headers': 'headers', 'status': 200, + 'duration': 120, 'response': 'Hey', 'response_same_as': None, })