hooks/test/unittest_bookmarks.py
author Alain Leufroy <alain.leufroy@logilab.fr>
Thu, 04 Mar 2010 08:50:27 +0100
branchstable
changeset 4781 d12cbd0b7574
parent 4051 eec34250a645
child 5223 6abd6e3599f4
child 5421 8167de96c523
permissions -rw-r--r--
Suppress the hidden logform when the user is already connected by adding a conditionned logform
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()