hooks/test/unittest_bookmarks.py
changeset 9855 f8e430fb4d07
parent 7791 31bb51ea5485
equal deleted inserted replaced
9854:4071c52b8fca 9855:f8e430fb4d07
     1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
    20 
    20 
    21 class BookmarkHooksTC(CubicWebTC):
    21 class BookmarkHooksTC(CubicWebTC):
    22 
    22 
    23 
    23 
    24     def test_auto_delete_bookmarks(self):
    24     def test_auto_delete_bookmarks(self):
    25         beid = self.execute('INSERT Bookmark X: X title "hop", X path "view", X bookmarked_by U '
    25         with self.admin_access.repo_cnx() as cnx:
    26                             'WHERE U login "admin"')[0][0]
    26             beid = cnx.execute('INSERT Bookmark X: X title "hop", X path "view", X bookmarked_by U '
    27         self.execute('SET X bookmarked_by U WHERE U login "anon"')
    27                                'WHERE U login "admin"')[0][0]
    28         self.commit()
    28             cnx.execute('SET X bookmarked_by U WHERE U login "anon"')
    29         self.execute('DELETE X bookmarked_by U WHERE U login "admin"')
    29             cnx.commit()
    30         self.commit()
    30             cnx.execute('DELETE X bookmarked_by U WHERE U login "admin"')
    31         self.assertTrue(self.execute('Any X WHERE X eid %(x)s', {'x': beid}))
    31             cnx.commit()
    32         self.execute('DELETE X bookmarked_by U WHERE U login "anon"')
    32             self.assertTrue(cnx.execute('Any X WHERE X eid %(x)s', {'x': beid}))
    33         self.commit()
    33             cnx.execute('DELETE X bookmarked_by U WHERE U login "anon"')
    34         self.assertFalse(self.execute('Any X WHERE X eid %(x)s', {'x': beid}))
    34             cnx.commit()
       
    35             self.assertFalse(cnx.execute('Any X WHERE X eid %(x)s', {'x': beid}))
    35 
    36 
    36 if __name__ == '__main__':
    37 if __name__ == '__main__':
    37     unittest_main()
    38     unittest_main()