15 self.add_entity('Bookmark', title=u"un signet !", path=u"view?vid=index") |
15 self.add_entity('Bookmark', title=u"un signet !", path=u"view?vid=index") |
16 self.add_entity('Comment', content=u"Yo !") |
16 self.add_entity('Comment', content=u"Yo !") |
17 self.execute('SET C comments B WHERE B title "une autre news !", C content "Yo !"') |
17 self.execute('SET C comments B WHERE B title "une autre news !", C content "Yo !"') |
18 self.vreg.config.global_set_option('supervising-addrs', 'test@logilab.fr') |
18 self.vreg.config.global_set_option('supervising-addrs', 'test@logilab.fr') |
19 |
19 |
20 |
20 |
21 def test_supervision(self): |
21 def test_supervision(self): |
22 session = self.session() |
22 session = self.session() |
23 # do some modification |
23 # do some modification |
24 ueid = self.execute('INSERT CWUser X: X login "toto", X upassword "sosafe", X in_group G, X in_state S ' |
24 ueid = self.execute('INSERT CWUser X: X login "toto", X upassword "sosafe", X in_group G, X in_state S ' |
25 'WHERE G name "users", S name "activated"')[0][0] |
25 'WHERE G name "users", S name "activated"')[0][0] |
26 self.execute('SET X last_login_time NOW WHERE X eid %(x)s', {'x': ueid}, 'x') |
26 self.execute('SET X last_login_time NOW WHERE X eid %(x)s', {'x': ueid}, 'x') |
27 self.execute('SET X in_state S WHERE X login "anon", S name "deactivated"') |
27 self.execute('SET X in_state S WHERE X login "anon", S name "deactivated"') |
28 self.execute('DELETE Card B WHERE B title "une news !"') |
28 self.execute('DELETE Card B WHERE B title "une news !"') |
29 self.execute('SET X bookmarked_by U WHERE X is Bookmark, U eid %(x)s', {'x': ueid}, 'x') |
29 self.execute('SET X bookmarked_by U WHERE X is Bookmark, U eid %(x)s', {'x': ueid}, 'x') |
30 self.execute('SET X content "duh?" WHERE X is Comment') |
30 self.execute('SET X content "duh?" WHERE X is Comment') |
36 # check view content |
36 # check view content |
37 op = sentops[0] |
37 op = sentops[0] |
38 view = sentops[0]._get_view() |
38 view = sentops[0]._get_view() |
39 self.assertEquals(view.recipients(), ['test@logilab.fr']) |
39 self.assertEquals(view.recipients(), ['test@logilab.fr']) |
40 self.assertEquals(view.subject(), '[data supervision] changes summary') |
40 self.assertEquals(view.subject(), '[data supervision] changes summary') |
41 data = view.dispatch(changes=session.query_data('pendingchanges')).strip() |
41 data = view.render(changes=session.query_data('pendingchanges')).strip() |
42 data = re.sub('#\d+', '#EID', data) |
42 data = re.sub('#\d+', '#EID', data) |
43 data = re.sub('/\d+', '/EID', data) |
43 data = re.sub('/\d+', '/EID', data) |
44 self.assertTextEquals('''user admin has made the following change(s): |
44 self.assertTextEquals('''user admin has made the following change(s): |
45 |
45 |
46 * added euser #EID (toto) |
46 * added euser #EID (toto) |
61 from state activated to state deactivated |
61 from state activated to state deactivated |
62 http://testing.fr/cubicweb/euser/anon''', |
62 http://testing.fr/cubicweb/euser/anon''', |
63 data) |
63 data) |
64 # check prepared email |
64 # check prepared email |
65 op._prepare_email() |
65 op._prepare_email() |
66 self.assertEquals(len(op.to_send), 1) |
66 self.assertEquals(len(op.to_send), 1) |
67 self.assert_(op.to_send[0][0]) |
67 self.assert_(op.to_send[0][0]) |
68 self.assertEquals(op.to_send[0][1], ['test@logilab.fr']) |
68 self.assertEquals(op.to_send[0][1], ['test@logilab.fr']) |
69 |
69 |
70 def test_nonregr1(self): |
70 def test_nonregr1(self): |
71 session = self.session() |
71 session = self.session() |
72 # do some unlogged modification |
72 # do some unlogged modification |
73 self.execute('SET X last_login_time NOW WHERE X eid %(x)s', {'x': session.user.eid}, 'x') |
73 self.execute('SET X last_login_time NOW WHERE X eid %(x)s', {'x': session.user.eid}, 'x') |
74 self.commit() # no crash |
74 self.commit() # no crash |
75 |
75 |
76 |
76 |
77 if __name__ == '__main__': |
77 if __name__ == '__main__': |
78 unittest_main() |
78 unittest_main() |