Changeset - 44835b81c956
[Not reviewed]
default
0 1 0
Thomas De Schampheleire - 10 years ago 2016-03-11 22:20:04
thomas.de.schampheleire@gmail.com
test_admin_notifications: fix index test dependency

The index test only worked because another test had prepared some database
state it relied on.

More specifically, the index test creates a notification
as a newly created user, but that user had not been committed to the
database yet. When running the index test standalone, this causes the error:

IntegrityError: (IntegrityError) NOT NULL constraint failed:
notifications.created_by u'INSERT INTO notifications (subject, body,
created_by, created_on, type) VALUES (?, ?, ?, ?, ?)'
(u'test_notification_1', u'notification_1', None, '2016-03-11
21:15:19.066402', u'message')

By committing the database after the user is created, the problem is solved.
1 file changed with 1 insertions and 0 deletions:
0 comments (0 inline, 0 general)
kallithea/tests/functional/test_admin_notifications.py
Show inline comments
 
@@ -15,12 +15,13 @@ class TestNotificationsController(TestCo
 
        self.log_user()
 

	
 
        u1 = UserModel().create_or_update(username='u1', password='qweqwe',
 
                                          email='u1@example.com',
 
                                          firstname=u'u1', lastname=u'u1')
 
        u1 = u1.user_id
 
        Session().commit()
 

	
 
        response = self.app.get(url('notifications'))
 
        response.mustcontain('<div class="table">No notifications here yet</div>')
 

	
 
        cur_user = self._get_logged_user()
 
        notif = NotificationModel().create(created_by=u1, subject=u'test_notification_1',
0 comments (0 inline, 0 general)