From bbfcf1828dd0487349d7dd9dfe054d102d2d2a5c Mon Sep 17 00:00:00 2001 From: Terje Kvernes Date: Fri, 31 May 2024 10:58:46 +0200 Subject: [PATCH] Fix uptime and meta tests. (#540) --- mreg/api/v1/tests/tests.py | 8 ++++---- mreg/api/views.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mreg/api/v1/tests/tests.py b/mreg/api/v1/tests/tests.py index 8adc925c..4a28e501 100644 --- a/mreg/api/v1/tests/tests.py +++ b/mreg/api/v1/tests/tests.py @@ -289,8 +289,8 @@ class APIMetaTestCase(MregAPITestCase): def test_meta_versions_admin_200_ok(self): response = self.assert_get_and_200("/api/meta/versions") for key in ('rest_framework_version', 'django_version', 'python_version'): - self.assertTrue(key in response.data) - print(key, response.data[key]) + with self.subTest(key=key): + self.assertTrue(key in response.data) def test_meta_versions_user_403_forbidden(self): self.client = self.get_token_client(superuser=False) @@ -300,8 +300,8 @@ def test_meta_heartbeat_user_200_ok(self): self.client = self.get_token_client(superuser=False) response = self.assert_get("/api/meta/heartbeat") for key in ('uptime', 'start_time'): - self.assertTrue(key in response.data) - print(key, response.data[key]) + with self.subTest(key=key): + self.assertTrue(key in response.data) class APIAutoupdateZonesTestCase(MregAPITestCase): diff --git a/mreg/api/views.py b/mreg/api/views.py index 601f2e64..48806ac9 100644 --- a/mreg/api/views.py +++ b/mreg/api/views.py @@ -81,7 +81,7 @@ class MetaHeartbeat(APIView): permission_classes = (IsAuthenticated,) def get(self, request: Request): - uptime = int(start_time - time.time()) + uptime = int(time.time() - start_time) data = { "start_time": start_time, "uptime": uptime,