Files
@ cac5109ac3b6
Branch filter:
Location: kallithea/rhodecode/tests/functional/test_admin_notifications.py - annotation
cac5109ac3b6
4.8 KiB
text/x-python
Notification system improvements
- deleting
- tests
- ui
- moved to separate controller
- deleting
- tests
- ui
- moved to separate controller
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 cac5109ac3b6 | from rhodecode.tests import *
from rhodecode.model.db import Notification, User, UserNotification
from rhodecode.model.user import UserModel
from rhodecode.model.notification import NotificationModel
class TestNotificationsController(TestController):
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
u2 = UserModel().create_or_update(username='u2', password='qweqwe',
email='u2@rhodecode.org',
name='u2', lastname='u2').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()
NotificationModel().create(created_by=u1, subject=u'test',
body=u'notification_1',
recipients=[cur_user])
response = self.app.get(url('notifications'))
self.assertTrue(u'notification_1' in response.body)
User.delete(u1)
User.delete(u2)
# 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')
# make two notifications
notification = NotificationModel().create(created_by=cur_user,
subject=u'test',
body=u'hi there',
recipients=[cur_user, u1, u2])
u1 = User.get(u1.user_id)
u2 = User.get(u2.user_id)
# check DB
self.assertEqual(u1.notifications, [notification])
self.assertEqual(u2.notifications, [notification])
cur_usr_id = cur_user.user_id
response = self.app.delete(url('notification',
notification_id=cur_usr_id))
cur_user = self._get_logged_user()
self.assertEqual(cur_user.notifications, [])
User.delete(u1.user_id)
User.delete(u2.user_id)
# 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,
subject='test',
body='hi there',
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'))
|