Hello,
> I am attempting to setup unit testing with Pylons 0.9.6.1, AuthKit
> 0.4.0 and SQLAlchemy 0.4.0 using the AuthKit database driver.
...
> Has anyone managed to these three work together and have functional
> unit testing? Thanks for any advice or suggestions that you could
> provide.
I have managed and I do a lot of testing with exactly this configuration.
Entry from my test.ini file:
sqlalchemy.url = sqlite:///:memory:
sqlalchemy.echo = false
authkit.setup.method = form, cookie
authkit.form.authenticate.user.data = admin:admin
My application works with OpenID but AuthKit's OpenID method is not
suitable for unit-testing. Because of that I set that AuthKit method
is form (while it means nothing in this context). While actually I
have proposed to AuthKit author to introduce stub method for
unit-testing (maybe in the future I will get rights to commit to
AuthKit :)).
And you should be able to test actually. To test AuthKit protected
methods you must specify REMOTE_USER (and maybe REMOTE_USER_DATA) in
extra_environ. E.g.:
self.app.get(url_for(controller='release', action='save', id=None),
params = {'author': 'test author',
'publisher': 'test publisher',
'date': '2007',
'name': 'test name'},
extra_environ = {'REMOTE_USER': 'test'})
> the error I am receiving when I attempt to run nosetests is that the "AuthKit
> database has already been setup."
I guess you have mis-configured something. I don't have experience
with forward method of AuthKit (which you are using I guess) but it
looks like that you do not clean-up database properly after each test.
Here is excerpt from my tests/__init__.py file. If you have something
similar it might be that tearDown method is missing something.
class TestModel(TestCase):
"""
We want the database to be created from scratch before each test
and dropped after
each test (thus making them unit tests).
"""
def setUp(self):
model.Session.remove()
model.metadata.create_all(model.Session.bind)
def tearDown(self):
model.metadata.drop_all(model.Session.bind)
class TestController(TestModel):
def __init__(self, *args, **kwargs):
wsgiapp = loadapp('config:test.ini', relative_to=conf_dir)
self.app = paste.fixture.TestApp(wsgiapp)
TestCase.__init__(self, *args, **kwargs)
HTH,
Dalius
http://blog.sandbox.lt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---