~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/canonical/launchpad/ftests/harness.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2005-11-18 05:11:00 UTC
  • mfrom: (1102.1.159 launchpad-branches)
  • Revision ID: pqm@pqm.ubuntu.com-20051118051100-b3c97d86dfa45faf
[r=SteveA] Merging bzr branch support

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
from canonical.config import config
17
17
from canonical.database.sqlbase import SQLBase, ZopelessTransactionManager
18
18
from canonical.lp import initZopeless
 
19
from canonical.launchpad.ftests import login, ANONYMOUS, logout
19
20
from canonical.launchpad.webapp.interfaces import ILaunchpadDatabaseAdapter
20
21
 
21
22
import sqlos
108
109
        super(LaunchpadFunctionalTestSetup, self).setUp()
109
110
        FunctionalTestSetup().setUp()
110
111
        _reconnect_sqlos(self.dbuser)
111
 
        
 
112
 
112
113
    def tearDown(self):
113
114
        FunctionalTestSetup().tearDown()
114
115
        _disconnect_sqlos()
136
137
 
137
138
 
138
139
class LaunchpadFunctionalTestCase(unittest.TestCase):
 
140
 
 
141
    def login(self, user=None):
 
142
        """Login the current zope request as user.
 
143
        
 
144
        If no user is provided, ANONYMOUS is used.
 
145
        """
 
146
        if user is None:
 
147
            user = ANONYMOUS
 
148
        login(user)
 
149
        self.__logged_in = True
 
150
 
139
151
    def setUp(self):
 
152
        unittest.TestCase.setUp(self)
140
153
        LaunchpadFunctionalTestSetup().setUp()
141
154
        self.zodb_db = FunctionalTestSetup().db
 
155
        self.__logged_in = False
142
156
 
143
157
    def tearDown(self):
 
158
        if self.__logged_in:
 
159
            logout()
 
160
            self.__logged_in = False
144
161
        LaunchpadFunctionalTestSetup().tearDown()
 
162
        unittest.TestCase.tearDown(self)
145
163
 
146
164
    def connect(self):
147
165
        return LaunchpadFunctionalTestSetup().connect()