hooks/test/unittest_bookmarks.py
changeset 11057 0b59724cb3f2
parent 11052 058bb3dc685f
child 11058 23eb30449fe5
equal deleted inserted replaced
11052:058bb3dc685f 11057:0b59724cb3f2
     1 # copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
       
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
       
     3 #
       
     4 # This file is part of CubicWeb.
       
     5 #
       
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
       
     7 # terms of the GNU Lesser General Public License as published by the Free
       
     8 # Software Foundation, either version 2.1 of the License, or (at your option)
       
     9 # any later version.
       
    10 #
       
    11 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT
       
    12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
       
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
       
    14 # details.
       
    15 #
       
    16 # You should have received a copy of the GNU Lesser General Public License along
       
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
       
    18 from logilab.common.testlib import unittest_main
       
    19 from cubicweb.devtools.testlib import CubicWebTC
       
    20 
       
    21 class BookmarkHooksTC(CubicWebTC):
       
    22 
       
    23 
       
    24     def test_auto_delete_bookmarks(self):
       
    25         with self.admin_access.repo_cnx() as cnx:
       
    26             beid = cnx.execute('INSERT Bookmark X: X title "hop", X path "view", X bookmarked_by U '
       
    27                                'WHERE U login "admin"')[0][0]
       
    28             cnx.execute('SET X bookmarked_by U WHERE U login "anon"')
       
    29             cnx.commit()
       
    30             cnx.execute('DELETE X bookmarked_by U WHERE U login "admin"')
       
    31             cnx.commit()
       
    32             self.assertTrue(cnx.execute('Any X WHERE X eid %(x)s', {'x': beid}))
       
    33             cnx.execute('DELETE X bookmarked_by U WHERE U login "anon"')
       
    34             cnx.commit()
       
    35             self.assertFalse(cnx.execute('Any X WHERE X eid %(x)s', {'x': beid}))
       
    36 
       
    37 if __name__ == '__main__':
       
    38     unittest_main()