[PATCH] tests: improve robustness of notifications tests
Thomas De Schampheleire
patrickdepinguin at gmail.com
Mon Jun 22 10:05:03 EDT 2015
# HG changeset patch
# User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
# Date 1434977761 -7200
# Mon Jun 22 14:56:01 2015 +0200
# Node ID bba51160f25cb009bbc411d962532c2249716cb8
# Parent 9a23b444a7fefe5b67e57a42d26343787d992874
tests: improve robustness of notifications tests
The notifications tests make the assumption that there are no notifications
at the start of the test, which is explicitly asserted.
However, any other test, like the one introduced in commit 9a23b444a7fe
(pullrequests: detect invalid reviewers and raise HTTPBadRequest), could add
new notifications to the database, and thus fail these assertions.
Just like the notifications tests already cleaned all notifications at the
end of the test (tearDown), make sure to clean them at the start (setUp)
too.
diff --git a/kallithea/tests/models/test_notifications.py b/kallithea/tests/models/test_notifications.py
--- a/kallithea/tests/models/test_notifications.py
+++ b/kallithea/tests/models/test_notifications.py
@@ -41,6 +41,9 @@ class TestNotifications(BaseTestCase):
Session().commit()
self.assertEqual(Notification.query().all(), [])
+ def setUp(self):
+ self._clean_notifications()
+
def tearDown(self):
self._clean_notifications()
@@ -156,7 +159,6 @@ class TestNotifications(BaseTestCase):
self.assertNotEqual(u2notification, None)
def test_notification_counter(self):
- self._clean_notifications()
self.assertEqual([], Notification.query().all())
self.assertEqual([], UserNotification.query().all())
More information about the kallithea-general
mailing list