changeset 5920:fed129fb8533

pytest migration: backout declassification of remove_all_notifications In order to accomodate both nose/unittest and pytest at the same time, method remove_all_notifications has been extracted from BaseTestCase in commit 37d713674f63. Now that nose/unittest is no longer used, we can backout this change again.
author Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
date Sat, 14 May 2016 21:59:47 +0200
parents acfd700770cc
children cbeed250b599
files kallithea/tests/__init__.py kallithea/tests/functional/test_admin_notifications.py kallithea/tests/functional/test_changeset_comments.py kallithea/tests/functional/test_login.py kallithea/tests/models/test_notifications.py
diffstat 5 files changed, 13 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/tests/__init__.py	Sat May 14 21:54:03 2016 +0200
+++ b/kallithea/tests/__init__.py	Sat May 14 21:59:47 2016 +0200
@@ -70,7 +70,7 @@
     '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', 'remove_all_notifications',
+    'GIT_REMOTE_REPO', 'SCM_TESTS',
 ]
 
 # Invoke websetup with the current config file
@@ -161,14 +161,6 @@
     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 TestControllerPytest(object):
     """Pytest-style test controller"""
@@ -184,6 +176,14 @@
         self.index_location = config['app_conf']['index_dir']
         return self.app
 
+    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()
+
     def log_user(self, username=TEST_USER_ADMIN_LOGIN,
                  password=TEST_USER_ADMIN_PASS):
         self._logged_username = username
--- a/kallithea/tests/functional/test_admin_notifications.py	Sat May 14 21:54:03 2016 +0200
+++ b/kallithea/tests/functional/test_admin_notifications.py	Sat May 14 21:59:47 2016 +0200
@@ -9,7 +9,7 @@
 
 class TestNotificationsController(TestControllerPytest):
     def setup_method(self, method):
-        remove_all_notifications()
+        self.remove_all_notifications()
 
     def test_index(self):
         self.log_user()
--- a/kallithea/tests/functional/test_changeset_comments.py	Sat May 14 21:54:03 2016 +0200
+++ b/kallithea/tests/functional/test_changeset_comments.py	Sat May 14 21:59:47 2016 +0200
@@ -11,7 +11,7 @@
             Session().delete(x)
         Session().commit()
 
-        remove_all_notifications()
+        self.remove_all_notifications()
 
     def test_create(self):
         self.log_user()
--- a/kallithea/tests/functional/test_login.py	Sat May 14 21:54:03 2016 +0200
+++ b/kallithea/tests/functional/test_login.py	Sat May 14 21:59:47 2016 +0200
@@ -21,7 +21,7 @@
 
 class TestLoginController(TestControllerPytest):
     def setup_method(self, method):
-        remove_all_notifications()
+        self.remove_all_notifications()
         assert Notification.query().all() == []
 
     def test_index(self):
--- a/kallithea/tests/models/test_notifications.py	Sat May 14 21:54:03 2016 +0200
+++ b/kallithea/tests/models/test_notifications.py	Sat May 14 21:59:47 2016 +0200
@@ -32,7 +32,7 @@
         Session().commit()
         self.u3 = self.u3.user_id
 
-        remove_all_notifications()
+        self.remove_all_notifications()
         assert [] == Notification.query().all()
         assert [] == UserNotification.query().all()