Пример #1
0
def _create_test_user():
    obj = User()
    obj.user_name = u"creosote"
    obj.email_address = u"*****@*****.**"
    obj.display_name = u"Mr Creosote"
    obj.password = u"Wafer-thin Mint"
    # mark object as 'to be saved'
    session.add(obj)
    # flush marked object to database
    session.flush()
    return obj
Пример #2
0
def _create_test_user():
    obj = User()
    obj.user_name = u"creosote"
    obj.email_address = u"*****@*****.**"
    obj.display_name = u"Mr Creosote"
    obj.password = u"Wafer-thin Mint"
    # mark object as 'to be saved'
    session.add(obj)
    # flush marked object to database
    session.flush()
    return obj
Пример #3
0
 def test_login_and_logout(self):
     """Login with correct credentials and then logout."""
     u = User()
     u.user_name = u"scott"
     u.password = u"tiger"
     u.display_name = u"Bruce Scott"
     u.email_address = u"*****@*****.**"
     session.add(u)
     session.flush()
     response = self.app.get('/')
     assert "<title>Welcome to TurboGears</title>" in response
     assert 'href="/login"' in response
     assert 'href="/logout"' not in response
     response = self.app.get('/login')
     assert "<title>Login</title>" in response
     assert 'Please log in.' in response
     cookie = ', '.join(map(str, response.cookies_set.values()))
     login = '******'
     headers = dict(Cookie=cookie)
     response = self.app.get(login, headers=headers, status=302)
     location = response.headers['Location']
     response = self.app.get(location, headers=headers)
     assert "<title>Welcome to TurboGears</title>" in response
     assert "Welcome Bruce Scott" in response
     assert 'href="/login"' not in response
     assert 'href="/logout"' in response
     response = self.app.get('/', headers=headers)
     assert "<title>Welcome to TurboGears</title>" in response
     assert "Welcome Bruce Scott" in response
     assert 'href="/login"' not in response
     assert 'href="/logout"' in response
     response = self.app.get('/logout', headers=headers, status=302)
     location = response.headers['Location']
     response = self.app.get(location, headers=headers)
     assert "<title>Welcome to TurboGears</title>" in response
     assert 'href="/login"' in response
     assert 'href="/logout"' not in response