]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git/commitdiff
Store duration in http requests
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 20 Apr 2018 18:07:03 +0000 (20:07 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 20 Apr 2018 18:07:03 +0000 (20:07 +0200)
store.py
tests/test_store.py

index 45a52339dc688bb9311451c476ec149b23f09a5f..0c018e017b062aed66fd558cafaa1ef10ed722d6 100644 (file)
--- 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,
                 })
index 4232fc3efa1b70c2dbd30aecc135b2fd86aaa7b1..e281adb3a62d2013d0acd090595263ff843f0461 100644 (file)
@@ -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,
                 })