hooks/test/unittest_bookmarks.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 18 Dec 2009 14:07:16 +0100
changeset 4135 cb0d0bf255f7
parent 4051 eec34250a645
child 5223 6abd6e3599f4
child 5421 8167de96c523
permissions -rw-r--r--
look for cubicweb-ctl plugins in the ccplugin.py file, keeping bw compat on ecplugin.py
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4051
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     1
"""
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     2
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     3
:organization: Logilab
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     4
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     5
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     6
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     7
"""
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     8
from logilab.common.testlib import unittest_main
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
     9
from cubicweb.devtools.testlib import CubicWebTC
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    10
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    11
class BookmarkHooksTC(CubicWebTC):
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    12
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    13
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    14
    def test_auto_delete_bookmarks(self):
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    15
        beid = self.execute('INSERT Bookmark X: X title "hop", X path "view", X bookmarked_by U '
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    16
                            'WHERE U login "admin"')[0][0]
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    17
        self.execute('SET X bookmarked_by U WHERE U login "anon"')
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    18
        self.commit()
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    19
        self.execute('DELETE X bookmarked_by U WHERE U login "admin"')
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    20
        self.commit()
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    21
        self.failUnless(self.execute('Any X WHERE X eid %(x)s', {'x': beid}, 'x'))
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    22
        self.execute('DELETE X bookmarked_by U WHERE U login "anon"')
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    23
        self.commit()
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    24
        self.failIf(self.execute('Any X WHERE X eid %(x)s', {'x': beid}, 'x'))
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    25
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    26
if __name__ == '__main__':
eec34250a645 move hook tests to hooks package tests
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff changeset
    27
    unittest_main()