diff --git a/kallithea/tests/__init__.py b/kallithea/tests/__init__.py --- a/kallithea/tests/__init__.py +++ b/kallithea/tests/__init__.py @@ -69,7 +69,7 @@ __all__ = [ 'TEST_USER_REGULAR2_PASS', 'TEST_USER_REGULAR2_EMAIL', 'TEST_HG_REPO', 'TEST_HG_REPO_CLONE', 'TEST_HG_REPO_PULL', 'TEST_GIT_REPO', 'TEST_GIT_REPO_CLONE', 'TEST_GIT_REPO_PULL', 'HG_REMOTE_REPO', - 'GIT_REMOTE_REPO', 'SCM_TESTS', + 'GIT_REMOTE_REPO', 'SCM_TESTS', 'remove_all_notifications', ] # Invoke websetup with the current config file @@ -160,6 +160,14 @@ def init_stack(config=None): h = NullHandler() logging.getLogger("kallithea").addHandler(h) +def remove_all_notifications(): + Notification.query().delete() + + # Because query().delete() does not (by default) trigger cascades. + # http://docs.sqlalchemy.org/en/rel_0_7/orm/collections.html#passive-deletes + UserNotification.query().delete() + + Session().commit() class BaseTestCase(unittest.TestCase): def __init__(self, *args, **kwargs): @@ -167,14 +175,7 @@ class BaseTestCase(unittest.TestCase): init_stack(self.wsgiapp.config) unittest.TestCase.__init__(self, *args, **kwargs) - def remove_all_notifications(self): - Notification.query().delete() - # Because query().delete() does not (by default) trigger cascades. - # http://docs.sqlalchemy.org/en/rel_0_7/orm/collections.html#passive-deletes - UserNotification.query().delete() - - Session().commit() class TestController(BaseTestCase): diff --git a/kallithea/tests/functional/test_admin_notifications.py b/kallithea/tests/functional/test_admin_notifications.py --- a/kallithea/tests/functional/test_admin_notifications.py +++ b/kallithea/tests/functional/test_admin_notifications.py @@ -9,7 +9,7 @@ from kallithea.lib import helpers as h class TestNotificationsController(TestController): def setUp(self): - self.remove_all_notifications() + remove_all_notifications() def test_index(self): self.log_user() diff --git a/kallithea/tests/functional/test_changeset_comments.py b/kallithea/tests/functional/test_changeset_comments.py --- a/kallithea/tests/functional/test_changeset_comments.py +++ b/kallithea/tests/functional/test_changeset_comments.py @@ -11,7 +11,7 @@ class TestChangeSetCommentsController(Te Session().delete(x) Session().commit() - self.remove_all_notifications() + remove_all_notifications() def test_create(self): self.log_user() diff --git a/kallithea/tests/functional/test_login.py b/kallithea/tests/functional/test_login.py --- a/kallithea/tests/functional/test_login.py +++ b/kallithea/tests/functional/test_login.py @@ -21,7 +21,7 @@ fixture = Fixture() class TestLoginController(TestController): def setUp(self): - self.remove_all_notifications() + remove_all_notifications() self.assertEqual(Notification.query().all(), []) def test_index(self): 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 @@ -35,7 +35,7 @@ class TestNotifications(BaseTestCase): super(TestNotifications, self).__init__(methodName=methodName) def setUp(self): - self.remove_all_notifications() + remove_all_notifications() self.assertEqual([], Notification.query().all()) self.assertEqual([], UserNotification.query().all())