From f593b7bba64a36c23a9e062dba0bacbdfa08f5fd Mon Sep 17 00:00:00 2001 From: thomahl <thomahl@stud.ntnu.no> Date: Wed, 15 Apr 2020 14:29:49 +0200 Subject: [PATCH] =?UTF-8?q?#112=20=C3=B8ker=20delta=20i=20alle=20tester=20?= =?UTF-8?q?&=20parameteriserer=20delta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test_database.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test_database.py b/test/test_database.py index 972314f..6f31468 100644 --- a/test/test_database.py +++ b/test/test_database.py @@ -17,6 +17,8 @@ TESTDBPATH = os.path.join(SOITOOL_DIR, TESTDBNAME) TESTDATA_PATH = Path(__file__).parent.parent / "soitool/testdata" +# Tolerance for timed tests. Tolrating DELTA seconds of difference +DELTA = 2 class DatabaseTest(unittest.TestCase): """Database tests.""" @@ -141,7 +143,7 @@ class DatabaseTest(unittest.TestCase): # Calculates difference in seconds time_diff = (second_time - first_time).total_seconds() # Compares difference with sleep_time - self.assertAlmostEqual(time_diff, sleep_time, delta=2) + self.assertAlmostEqual(time_diff, sleep_time, delta=DELTA) def test_get_categories(self): """Assert function get_categories works as expected.""" @@ -276,7 +278,7 @@ class DatabaseTest(unittest.TestCase): expected_time = seconds_in_24h - sleep_time actual_time = self.database.seconds_to_next_update(seconds_in_24h) # Compares expected and function return value with - self.assertAlmostEqual(expected_time, actual_time, delta=0.2) + self.assertAlmostEqual(expected_time, actual_time, delta=DELTA) def teset_seconds_to_next_update_complete_period(self): """Check that seconds to next update can returns 0 and not negative.""" -- GitLab