26 |
26 |
27 |
27 |
28 def test_supervision(self): |
28 def test_supervision(self): |
29 session = self.session |
29 session = self.session |
30 # do some modification |
30 # do some modification |
31 ueid = self.execute('INSERT CWUser X: X login "toto", X upassword "sosafe", X in_group G, X in_state S ' |
31 user = self.execute('INSERT CWUser X: X login "toto", X upassword "sosafe", X in_group G ' |
32 'WHERE G name "users", S name "activated"')[0][0] |
32 'WHERE G name "users"').get_entity(0, 0) |
33 self.execute('SET X last_login_time NOW WHERE X eid %(x)s', {'x': ueid}, 'x') |
33 self.execute('SET X last_login_time NOW WHERE X eid %(x)s', {'x': user.eid}, 'x') |
34 self.execute('SET X in_state S WHERE X login "anon", S name "deactivated"') |
|
35 self.execute('DELETE Card B WHERE B title "une news !"') |
34 self.execute('DELETE Card B WHERE B title "une news !"') |
36 self.execute('SET X bookmarked_by U WHERE X is Bookmark, U eid %(x)s', {'x': ueid}, 'x') |
35 self.execute('SET X bookmarked_by U WHERE X is Bookmark, U eid %(x)s', {'x': user.eid}, 'x') |
37 self.execute('SET X content "duh?" WHERE X is Comment') |
36 self.execute('SET X content "duh?" WHERE X is Comment') |
38 self.execute('DELETE X comments Y WHERE Y is Card, Y title "une autre news !"') |
37 self.execute('DELETE X comments Y WHERE Y is Card, Y title "une autre news !"') |
39 # check only one supervision email operation |
38 # check only one supervision email operation |
40 sentops = [op for op in session.pending_operations |
39 sentops = [op for op in session.pending_operations |
41 if isinstance(op, SupervisionMailOp)] |
40 if isinstance(op, SupervisionMailOp)] |
60 * added relation bookmarked_by from bookmark #EID to cwuser #EID |
59 * added relation bookmarked_by from bookmark #EID to cwuser #EID |
61 |
60 |
62 * updated comment #EID (#EID) |
61 * updated comment #EID (#EID) |
63 http://testing.fr/cubicweb/comment/EID |
62 http://testing.fr/cubicweb/comment/EID |
64 |
63 |
65 * deleted relation comments from comment #EID to card #EID |
64 * deleted relation comments from comment #EID to card #EID''', |
66 |
|
67 * changed state of cwuser #EID (anon) |
|
68 from state activated to state deactivated |
|
69 http://testing.fr/cubicweb/cwuser/anon''', |
|
70 data) |
65 data) |
71 # check prepared email |
66 # check prepared email |
72 op._prepare_email() |
67 op._prepare_email() |
73 self.assertEquals(len(op.to_send), 1) |
68 self.assertEquals(len(op.to_send), 1) |
74 self.assert_(op.to_send[0][0]) |
69 self.assert_(op.to_send[0][0]) |
75 self.assertEquals(op.to_send[0][1], ['test@logilab.fr']) |
70 self.assertEquals(op.to_send[0][1], ['test@logilab.fr']) |
|
71 self.commit() |
|
72 # some other changes ####### |
|
73 user.fire_transition('deactivate') |
|
74 sentops = [op for op in session.pending_operations |
|
75 if isinstance(op, SupervisionMailOp)] |
|
76 self.assertEquals(len(sentops), 1) |
|
77 # check view content |
|
78 op = sentops[0] |
|
79 view = sentops[0]._get_view() |
|
80 data = view.render(changes=session.transaction_data.get('pendingchanges')).strip() |
|
81 data = re.sub('#\d+', '#EID', data) |
|
82 data = re.sub('/\d+', '/EID', data) |
|
83 self.assertTextEquals('''user admin has made the following change(s): |
|
84 |
|
85 * changed state of cwuser #EID (toto) |
|
86 from state activated to state deactivated |
|
87 http://testing.fr/cubicweb/cwuser/toto''', |
|
88 data) |
76 |
89 |
77 def test_nonregr1(self): |
90 def test_nonregr1(self): |
78 session = self.session |
91 session = self.session |
79 # do some unlogged modification |
92 # do some unlogged modification |
80 self.execute('SET X last_login_time NOW WHERE X eid %(x)s', {'x': session.user.eid}, 'x') |
93 self.execute('SET X last_login_time NOW WHERE X eid %(x)s', {'x': session.user.eid}, 'x') |