# HG changeset patch # User Sylvain Thénault # Date 1260291897 -3600 # Node ID eec34250a6456bbcd61abfc4fd7fd1b2f3c83f45 # Parent f2e1bb4b75369e14ee60010da7460df402b29983 move hook tests to hooks package tests diff -r f2e1bb4b7536 -r eec34250a645 hooks/test/unittest_bookmarks.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hooks/test/unittest_bookmarks.py Tue Dec 08 18:04:57 2009 +0100 @@ -0,0 +1,27 @@ +""" + +:organization: Logilab +:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. +:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr +:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses +""" +from logilab.common.testlib import unittest_main +from cubicweb.devtools.testlib import CubicWebTC + +class BookmarkHooksTC(CubicWebTC): + + + def test_auto_delete_bookmarks(self): + beid = self.execute('INSERT Bookmark X: X title "hop", X path "view", X bookmarked_by U ' + 'WHERE U login "admin"')[0][0] + self.execute('SET X bookmarked_by U WHERE U login "anon"') + self.commit() + self.execute('DELETE X bookmarked_by U WHERE U login "admin"') + self.commit() + self.failUnless(self.execute('Any X WHERE X eid %(x)s', {'x': beid}, 'x')) + self.execute('DELETE X bookmarked_by U WHERE U login "anon"') + self.commit() + self.failIf(self.execute('Any X WHERE X eid %(x)s', {'x': beid}, 'x')) + +if __name__ == '__main__': + unittest_main() diff -r f2e1bb4b7536 -r eec34250a645 hooks/test/unittest_hooks.py --- a/hooks/test/unittest_hooks.py Tue Dec 08 18:04:29 2009 +0100 +++ b/hooks/test/unittest_hooks.py Tue Dec 08 18:04:57 2009 +0100 @@ -167,6 +167,16 @@ self.assertEquals(len(entity.owned_by), 1) # make sure we have only one owner self.assertEquals(entity.owned_by[0].eid, self.session.user.eid) + def test_user_login_stripped(self): + u = self.create_user(' joe ') + tname = self.execute('Any L WHERE E login L, E eid %(e)s', + {'e': u.eid})[0][0] + self.assertEquals(tname, 'joe') + self.execute('SET X login " jijoe " WHERE X eid %(x)s', {'x': u.eid}) + tname = self.execute('Any L WHERE E login L, E eid %(e)s', + {'e': u.eid})[0][0] + self.assertEquals(tname, 'jijoe') + class UserGroupHooksTC(CubicWebTC): diff -r f2e1bb4b7536 -r eec34250a645 sobjects/test/unittest_hooks.py --- a/sobjects/test/unittest_hooks.py Tue Dec 08 18:04:29 2009 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -""" - -:organization: Logilab -:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. -:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr -:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses -""" -from logilab.common.testlib import unittest_main -from cubicweb.devtools.testlib import CubicWebTC - -class HooksTC(CubicWebTC): - - def test_euser_login_stripped(self): - u = self.create_user(' joe ') - tname = self.execute('Any L WHERE E login L, E eid %(e)s', - {'e': u.eid})[0][0] - self.assertEquals(tname, 'joe') - self.execute('SET X login " jijoe " WHERE X eid %(x)s', {'x': u.eid}) - tname = self.execute('Any L WHERE E login L, E eid %(e)s', - {'e': u.eid})[0][0] - self.assertEquals(tname, 'jijoe') - - - def test_auto_delete_bookmarks(self): - beid = self.execute('INSERT Bookmark X: X title "hop", X path "view", X bookmarked_by U ' - 'WHERE U login "admin"')[0][0] - self.execute('SET X bookmarked_by U WHERE U login "anon"') - self.commit() - self.execute('DELETE X bookmarked_by U WHERE U login "admin"') - self.commit() - self.failUnless(self.execute('Any X WHERE X eid %(x)s', {'x': beid}, 'x')) - self.execute('DELETE X bookmarked_by U WHERE U login "anon"') - self.commit() - self.failIf(self.execute('Any X WHERE X eid %(x)s', {'x': beid}, 'x')) - -if __name__ == '__main__': - unittest_main()