Changeset - 77bd10c410ed
[Not reviewed]
default
0 1 0
domruf - 9 years ago 2016-06-17 19:22:53
dominikruf@gmail.com
tests: fix 'a foreign key constraint fails' when running tests on mysql

UserNotification needs to be deleted before Notification because there are
foreign key references in UserNotification to Notification.
1 file changed with 5 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/__init__.py
Show inline comments
 
@@ -172,17 +172,18 @@ class TestController(object):
 
        translator = _get_translator(pylons.config.get('lang'))
 
        pylons.translator._push_object(translator)
 
        h = NullHandler()
 
        logging.getLogger("kallithea").addHandler(h)
 

	
 
    def remove_all_notifications(self):
 
        Notification.query().delete()
 
        # query().delete() does not (by default) trigger cascades
 
        # ( http://docs.sqlalchemy.org/en/rel_0_7/orm/collections.html#passive-deletes )
 
        # so delete the UserNotification first to ensure referential integrity.
 
        UserNotification.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()
 
        Notification.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'),
0 comments (0 inline, 0 general)