##// END OF EJS Templates
Added localization for the “quick filter” menu item and improved localization on the followers page.
Added localization for the “quick filter” menu item and improved localization on the followers page.

File last commit:

r1749:8ecc6b82 beta
r2420:a78cd80a beta
Show More
test_admin_notifications.py
119 lines | 4.9 KiB | text/x-python | PythonLexer
/ rhodecode / tests / functional / test_admin_notifications.py
Notification system improvements...
r1712 from rhodecode.tests import *
from rhodecode.model.db import Notification, User, UserNotification
from rhodecode.model.user import UserModel
from rhodecode.model.notification import NotificationModel
Tests updates, Session refactoring
r1713 from rhodecode.model.meta import Session
Notification system improvements...
r1712
class TestNotificationsController(TestController):
Tests updates, Session refactoring
r1713
def tearDown(self):
for n in Notification.query().all():
inst = Notification.get(n.notification_id)
commit less models...
r1749 Session.delete(inst)
Session.commit()
Tests updates, Session refactoring
r1713
Notification system improvements...
r1712 def test_index(self):
self.log_user()
u1 = UserModel().create_or_update(username='u1', password='qweqwe',
email='u1@rhodecode.org',
name='u1', lastname='u1').user_id
response = self.app.get(url('notifications'))
self.assertTrue('''<div class="table">No notifications here yet</div>'''
in response.body)
cur_user = self._get_logged_user()
Tests updates, Session refactoring
r1713 NotificationModel().create(created_by=u1, subject=u'test_notification_1',
Notification system improvements...
r1712 body=u'notification_1',
recipients=[cur_user])
commit less models...
r1749 Session.commit()
Notification system improvements...
r1712 response = self.app.get(url('notifications'))
Tests updates, Session refactoring
r1713 self.assertTrue(u'test_notification_1' in response.body)
Notification system improvements...
r1712
# def test_index_as_xml(self):
# response = self.app.get(url('formatted_notifications', format='xml'))
#
# def test_create(self):
# response = self.app.post(url('notifications'))
#
# def test_new(self):
# response = self.app.get(url('new_notification'))
#
# def test_new_as_xml(self):
# response = self.app.get(url('formatted_new_notification', format='xml'))
#
# def test_update(self):
# response = self.app.put(url('notification', notification_id=1))
#
# def test_update_browser_fakeout(self):
# response = self.app.post(url('notification', notification_id=1), params=dict(_method='put'))
def test_delete(self):
self.log_user()
cur_user = self._get_logged_user()
u1 = UserModel().create_or_update(username='u1', password='qweqwe',
email='u1@rhodecode.org',
name='u1', lastname='u1')
u2 = UserModel().create_or_update(username='u2', password='qweqwe',
email='u2@rhodecode.org',
name='u2', lastname='u2')
Tests updates, Session refactoring
r1713 # make notifications
Notification system improvements...
r1712 notification = NotificationModel().create(created_by=cur_user,
subject=u'test',
body=u'hi there',
recipients=[cur_user, u1, u2])
commit less models...
r1749 Session.commit()
Notification system improvements...
r1712 u1 = User.get(u1.user_id)
u2 = User.get(u2.user_id)
# check DB
Tests updates, Session refactoring
r1713 get_notif = lambda un:[x.notification for x in un]
self.assertEqual(get_notif(cur_user.notifications), [notification])
self.assertEqual(get_notif(u1.notifications), [notification])
self.assertEqual(get_notif(u2.notifications), [notification])
Notification system improvements...
r1712 cur_usr_id = cur_user.user_id
Tests updates, Session refactoring
r1713
Notification system improvements...
r1712
Tests updates, Session refactoring
r1713 response = self.app.delete(url('notification',
notification_id=
notification.notification_id))
Notification system improvements...
r1712
Tests updates, Session refactoring
r1713 cur_user = User.get(cur_usr_id)
self.assertEqual(cur_user.notifications, [])
Notification system improvements...
r1712
# def test_delete_browser_fakeout(self):
# response = self.app.post(url('notification', notification_id=1), params=dict(_method='delete'))
def test_show(self):
self.log_user()
cur_user = self._get_logged_user()
u1 = UserModel().create_or_update(username='u1', password='qweqwe',
email='u1@rhodecode.org',
name='u1', lastname='u1')
u2 = UserModel().create_or_update(username='u2', password='qweqwe',
email='u2@rhodecode.org',
name='u2', lastname='u2')
notification = NotificationModel().create(created_by=cur_user,
- refactoring to overcome poor usage of global pylons config...
r1723 subject=u'test',
Tests updates, Session refactoring
r1713 body=u'hi there',
Notification system improvements...
r1712 recipients=[cur_user, u1, u2])
response = self.app.get(url('notification',
notification_id=notification.notification_id))
# def test_show_as_xml(self):
# response = self.app.get(url('formatted_notification', notification_id=1, format='xml'))
#
# def test_edit(self):
# response = self.app.get(url('edit_notification', notification_id=1))
#
# def test_edit_as_xml(self):
# response = self.app.get(url('formatted_edit_notification', notification_id=1, format='xml'))