1 """ |
|
2 |
|
3 :organization: Logilab |
|
4 :copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
|
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
|
6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
|
7 """ |
|
8 from logilab.common.testlib import unittest_main |
|
9 from cubicweb.devtools.apptest import EnvBasedTC |
|
10 |
|
11 class HooksTC(EnvBasedTC): |
|
12 |
|
13 def test_euser_login_stripped(self): |
|
14 u = self.create_user(' joe ') |
|
15 tname = self.execute('Any L WHERE E login L, E eid %(e)s', |
|
16 {'e': u.eid})[0][0] |
|
17 self.assertEquals(tname, 'joe') |
|
18 self.execute('SET X login " jijoe " WHERE X eid %(x)s', {'x': u.eid}) |
|
19 tname = self.execute('Any L WHERE E login L, E eid %(e)s', |
|
20 {'e': u.eid})[0][0] |
|
21 self.assertEquals(tname, 'jijoe') |
|
22 |
|
23 |
|
24 def test_auto_delete_bookmarks(self): |
|
25 beid = self.execute('INSERT Bookmark X: X title "hop", X path "view", X bookmarked_by U ' |
|
26 'WHERE U login "admin"')[0][0] |
|
27 self.execute('SET X bookmarked_by U WHERE U login "anon"') |
|
28 self.commit() |
|
29 self.execute('DELETE X bookmarked_by U WHERE U login "admin"') |
|
30 self.commit() |
|
31 self.failUnless(self.execute('Any X WHERE X eid %(x)s', {'x': beid}, 'x')) |
|
32 self.execute('DELETE X bookmarked_by U WHERE U login "anon"') |
|
33 self.commit() |
|
34 self.failIf(self.execute('Any X WHERE X eid %(x)s', {'x': beid}, 'x')) |
|
35 |
|
36 if __name__ == '__main__': |
|
37 unittest_main() |
|