Changeset - fed129fb8533
[Not reviewed]
default
0 5 0
Thomas De Schampheleire - 10 years ago 2016-05-14 21:59:47
thomas.de.schampheleire@gmail.com
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.
5 files changed with 13 insertions and 13 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/__init__.py
Show inline comments
 
@@ -67,13 +67,13 @@ __all__ = [
 
    'HG_FORK', 'GIT_FORK', 'TEST_USER_ADMIN_LOGIN', 'TEST_USER_ADMIN_PASS',
 
    'TEST_USER_ADMIN_EMAIL', 'TEST_USER_REGULAR_LOGIN', 'TEST_USER_REGULAR_PASS',
 
    'TEST_USER_REGULAR_EMAIL', 'TEST_USER_REGULAR2_LOGIN',
 
    '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
 
# SetupCommand('setup-app').run([config_file])
 

	
 
environ = {}
 
@@ -158,20 +158,12 @@ def init_stack(config=None):
 
    # Initialize a translator for tests that utilize i18n
 
    translator = _get_translator(pylons.config.get('lang'))
 
    pylons.translator._push_object(translator)
 
    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"""
 

	
 
    # Note: pytest base classes cannot have an __init__ method
 

	
 
@@ -181,12 +173,20 @@ class TestControllerPytest(object):
 
        init_stack(self.wsgiapp.config)
 
        self.app = TestApp(self.wsgiapp)
 
        self.maxDiff = None
 
        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
 
        response = self.app.post(url(controller='login', action='index'),
 
                                 {'username': username,
 
                                  'password': password})
kallithea/tests/functional/test_admin_notifications.py
Show inline comments
 
@@ -6,13 +6,13 @@ from kallithea.model.notification import
 
from kallithea.model.meta import Session
 
from kallithea.lib import helpers as h
 

	
 

	
 
class TestNotificationsController(TestControllerPytest):
 
    def setup_method(self, method):
 
        remove_all_notifications()
 
        self.remove_all_notifications()
 

	
 
    def test_index(self):
 
        self.log_user()
 

	
 
        u1 = UserModel().create_or_update(username='u1', password='qweqwe',
 
                                          email='u1@example.com',
kallithea/tests/functional/test_changeset_comments.py
Show inline comments
 
@@ -8,13 +8,13 @@ class TestChangeSetCommentsController(Te
 

	
 
    def setup_method(self, method):
 
        for x in ChangesetComment.query().all():
 
            Session().delete(x)
 
        Session().commit()
 

	
 
        remove_all_notifications()
 
        self.remove_all_notifications()
 

	
 
    def test_create(self):
 
        self.log_user()
 
        rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
 
        text = u'CommentOnRevision'
 

	
kallithea/tests/functional/test_login.py
Show inline comments
 
@@ -18,13 +18,13 @@ from kallithea.model.user import UserMod
 

	
 
fixture = Fixture()
 

	
 

	
 
class TestLoginController(TestControllerPytest):
 
    def setup_method(self, method):
 
        remove_all_notifications()
 
        self.remove_all_notifications()
 
        assert Notification.query().all() == []
 

	
 
    def test_index(self):
 
        response = self.app.get(url(controller='login', action='index'))
 
        assert response.status == '200 OK'
 
        # Test response...
kallithea/tests/models/test_notifications.py
Show inline comments
 
@@ -29,13 +29,13 @@ class TestNotifications(TestControllerPy
 
                                        password=u'qweqwe',
 
                                        email=u'u3@example.com',
 
                                        firstname=u'u3', lastname=u'u3')
 
        Session().commit()
 
        self.u3 = self.u3.user_id
 

	
 
        remove_all_notifications()
 
        self.remove_all_notifications()
 
        assert [] == Notification.query().all()
 
        assert [] == UserNotification.query().all()
 

	
 
    def test_create_notification(self):
 
        usrs = [self.u1, self.u2]
 
        notification = NotificationModel().create(created_by=self.u1,
0 comments (0 inline, 0 general)