Hello,
I'm getting the following exception when I add the attached test case to the
test suite of a quickstarted application:
> OperationalError: (OperationalError) no such table: tg_user u'SELECT
> tg_user.password AS tg_user_password, tg_user.user_id AS tg_user_user_id,
> tg_user.user_name AS tg_user_user_name, tg_user.email_address AS
> tg_user_email_address, tg_user.display_name AS tg_user_display_name,
> tg_user.created AS tg_user_created \nFROM tg_user \nWHERE tg_user.user_name
> = ? \n LIMIT 2 OFFSET 0' ['manager']
I've spent a lot of time on this, but I've not been able to solve it. I have
not idea why that table is apparently not created.
Does anybody know what is going on?
Cheers.
--
Gustavo Narea <http://gustavonarea.net/>.
Get rid of unethical constraints! Get freedomware:
http://www.getgnulinux.org/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Trunk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears-trunk?hl=en
-~----------~----~----~----~------~----~------~--~---
from authproj.model import DBSession, User
from authproj.tests import TestController
class TestAuthentication(TestController):
def test_it(self):
manager = DBSession.query(User).get(u'manager')
assert manager is not None
def test_it2(self):
editor = DBSession.query(User).get(u'editor')
assert editor is not None
def test_forced_login(self):
# Requesting a protected area
resp = self.app.get('/admin/', status=302)
assert resp.location.startswith('http://localhost/login')
# Getting the login form:
resp = resp.follow(status=200)
form = resp.form
# Submitting the login form:
form['login'] = u'manager'
form['password'] = 'managepass'
post_login = form.submit(status=302)
# Being redirected to the initially requested page:
assert post_login.location.startswith('http://localhost/welcome_back')
initial_page = post_login.follow(status=302)
assert 'authtkt' in initial_page.request.cookies, \
"Session cookie wasn't defined: %s" % initial_page.request.cookies
assert initial_page.location.startswith('http://localhost/admin/'), \
initial_page.location
def test_voluntary_login(self):
# Going to the login form voluntarily:
resp = self.app.get('/login', status=200)
form = resp.form
# Submitting the login form:
form['login'] = u'manager'
form['password'] = 'managepass'
post_login = form.submit(status=302)
# Being redirected to the home page:
assert post_login.location.startswith('http://localhost/welcome_back')
home_page = post_login.follow(status=302)
assert 'authtkt' in home_page.request.cookies, \
'Session cookie was not defined: %s' % home_page.request.cookies
assert home_page.location == 'http://localhost/'
def test_logout(self):
# Logging in voluntarily:
resp = self.app.get('/login_handler?login=manager&password=managepass',
status=302)
resp = resp.follow(status=302)
assert 'authtkt' in resp.request.cookies, \
'Session cookie was not defined: %s' % resp.request.cookies
# Logging out:
resp = self.app.get('/logout_handler', status=302)
assert resp.location.startswith('http://localhost/see_you_later')
# Finally, redirected to the home page:
home_page = resp.follow(status=302)
assert 'authtkt' not in home_page.request.cookies, \
'Session cookie was not deleted: %s' % home_page.request.cookies
assert home_page.location == 'http://localhost/', home_page.location