Mercurial > kallithea
comparison rhodecode/tests/functional/test_admin_notifications.py @ 2513:388843a3a3c0 beta
Updated create_or_update method to not change API key when password is not updated
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 26 Jun 2012 21:57:31 +0200 |
parents | 8ecc6b8229a5 |
children | 40b3a54391f9 |
comparison
equal
deleted
inserted
replaced
2512:8ece6d04a282 | 2513:388843a3a3c0 |
---|---|
3 | 3 |
4 from rhodecode.model.user import UserModel | 4 from rhodecode.model.user import UserModel |
5 from rhodecode.model.notification import NotificationModel | 5 from rhodecode.model.notification import NotificationModel |
6 from rhodecode.model.meta import Session | 6 from rhodecode.model.meta import Session |
7 | 7 |
8 | |
8 class TestNotificationsController(TestController): | 9 class TestNotificationsController(TestController): |
9 | |
10 | 10 |
11 def tearDown(self): | 11 def tearDown(self): |
12 for n in Notification.query().all(): | 12 for n in Notification.query().all(): |
13 inst = Notification.get(n.notification_id) | 13 inst = Notification.get(n.notification_id) |
14 Session.delete(inst) | 14 Session.delete(inst) |
17 def test_index(self): | 17 def test_index(self): |
18 self.log_user() | 18 self.log_user() |
19 | 19 |
20 u1 = UserModel().create_or_update(username='u1', password='qweqwe', | 20 u1 = UserModel().create_or_update(username='u1', password='qweqwe', |
21 email='u1@rhodecode.org', | 21 email='u1@rhodecode.org', |
22 name='u1', lastname='u1').user_id | 22 firstname='u1', lastname='u1') |
23 u1 = u1.user_id | |
23 | 24 |
24 response = self.app.get(url('notifications')) | 25 response = self.app.get(url('notifications')) |
25 self.assertTrue('''<div class="table">No notifications here yet</div>''' | 26 self.assertTrue('''<div class="table">No notifications here yet</div>''' |
26 in response.body) | 27 in response.body) |
27 | 28 |
56 self.log_user() | 57 self.log_user() |
57 cur_user = self._get_logged_user() | 58 cur_user = self._get_logged_user() |
58 | 59 |
59 u1 = UserModel().create_or_update(username='u1', password='qweqwe', | 60 u1 = UserModel().create_or_update(username='u1', password='qweqwe', |
60 email='u1@rhodecode.org', | 61 email='u1@rhodecode.org', |
61 name='u1', lastname='u1') | 62 firstname='u1', lastname='u1') |
62 u2 = UserModel().create_or_update(username='u2', password='qweqwe', | 63 u2 = UserModel().create_or_update(username='u2', password='qweqwe', |
63 email='u2@rhodecode.org', | 64 email='u2@rhodecode.org', |
64 name='u2', lastname='u2') | 65 firstname='u2', lastname='u2') |
65 | 66 |
66 # make notifications | 67 # make notifications |
67 notification = NotificationModel().create(created_by=cur_user, | 68 notification = NotificationModel().create(created_by=cur_user, |
68 subject=u'test', | 69 subject=u'test', |
69 body=u'hi there', | 70 body=u'hi there', |
71 Session.commit() | 72 Session.commit() |
72 u1 = User.get(u1.user_id) | 73 u1 = User.get(u1.user_id) |
73 u2 = User.get(u2.user_id) | 74 u2 = User.get(u2.user_id) |
74 | 75 |
75 # check DB | 76 # check DB |
76 get_notif = lambda un:[x.notification for x in un] | 77 get_notif = lambda un: [x.notification for x in un] |
77 self.assertEqual(get_notif(cur_user.notifications), [notification]) | 78 self.assertEqual(get_notif(cur_user.notifications), [notification]) |
78 self.assertEqual(get_notif(u1.notifications), [notification]) | 79 self.assertEqual(get_notif(u1.notifications), [notification]) |
79 self.assertEqual(get_notif(u2.notifications), [notification]) | 80 self.assertEqual(get_notif(u2.notifications), [notification]) |
80 cur_usr_id = cur_user.user_id | 81 cur_usr_id = cur_user.user_id |
81 | |
82 | 82 |
83 response = self.app.delete(url('notification', | 83 response = self.app.delete(url('notification', |
84 notification_id= | 84 notification_id= |
85 notification.notification_id)) | 85 notification.notification_id)) |
86 | 86 |
87 cur_user = User.get(cur_usr_id) | 87 cur_user = User.get(cur_usr_id) |
88 self.assertEqual(cur_user.notifications, []) | 88 self.assertEqual(cur_user.notifications, []) |
89 | 89 |
90 | |
91 # def test_delete_browser_fakeout(self): | |
92 # response = self.app.post(url('notification', notification_id=1), params=dict(_method='delete')) | |
93 | |
94 def test_show(self): | 90 def test_show(self): |
95 self.log_user() | 91 self.log_user() |
96 cur_user = self._get_logged_user() | 92 cur_user = self._get_logged_user() |
97 u1 = UserModel().create_or_update(username='u1', password='qweqwe', | 93 u1 = UserModel().create_or_update(username='u1', password='qweqwe', |
98 email='u1@rhodecode.org', | 94 email='u1@rhodecode.org', |
99 name='u1', lastname='u1') | 95 firstname='u1', lastname='u1') |
100 u2 = UserModel().create_or_update(username='u2', password='qweqwe', | 96 u2 = UserModel().create_or_update(username='u2', password='qweqwe', |
101 email='u2@rhodecode.org', | 97 email='u2@rhodecode.org', |
102 name='u2', lastname='u2') | 98 firstname='u2', lastname='u2') |
103 | 99 |
104 notification = NotificationModel().create(created_by=cur_user, | 100 notification = NotificationModel().create(created_by=cur_user, |
105 subject=u'test', | 101 subject=u'test', |
106 body=u'hi there', | 102 body=u'hi there', |
107 recipients=[cur_user, u1, u2]) | 103 recipients=[cur_user, u1, u2]) |
108 | 104 |
109 response = self.app.get(url('notification', | 105 response = self.app.get(url('notification', |
110 notification_id=notification.notification_id)) | 106 notification_id=notification.notification_id)) |
111 | |
112 # def test_show_as_xml(self): | |
113 # response = self.app.get(url('formatted_notification', notification_id=1, format='xml')) | |
114 # | |
115 # def test_edit(self): | |
116 # response = self.app.get(url('edit_notification', notification_id=1)) | |
117 # | |
118 # def test_edit_as_xml(self): | |
119 # response = self.app.get(url('formatted_edit_notification', notification_id=1, format='xml')) |