Re: emulating an existing session in tests

2007-08-20 Thread omat
If I am not missing something, it looks like I have solved the problem. This is hack: >>> from django.http import SimpleCookie >>> from django.test.client import Client >>> c = Client() >>> cookies = SimpleCookie() >>> cookies['sessionid'] = '8a3dd9235b8e718c3f7e890106180528' >>> c.cookies = coo

Re: emulating an existing session in tests

2007-08-20 Thread omat
I am using the api via shell (i.e.: python manage.py shell) as follows: >>> from django.contrib.sessions.middleware import SessionWrapper >>> from django.test.client import Client >>> c = Client() >>> s = SessionWrapper('8a3dd9235b8e718c3f7e890106180528') >>> c.session = s._session >>> c.session

Re: emulating an existing session in tests

2007-08-20 Thread Malcolm Tredinnick
On Mon, 2007-08-20 at 09:57 +, omat wrote: > Thanks for the reply... > > I used the existing database instead of the test database to hook to > the user's session like this: > > from django.test.client import Client > from django.contrib.sessions.models import Session > > client = Client()

Re: emulating an existing session in tests

2007-08-20 Thread omat
Thanks for the reply... I used the existing database instead of the test database to hook to the user's session like this: from django.test.client import Client from django.contrib.sessions.models import Session client = Client() client.session = Session.objects.get(session_key = key_from_trace

Re: emulating an existing session in tests

2007-08-20 Thread Malcolm Tredinnick
On Mon, 2007-08-20 at 09:13 +, omat wrote: > There is an error that occurs occasionally and I suspect that it may > be user specific (i.e. for users with certain credentials). > > I need to run tests in the user's context, thus, I need to emulate the > existing session of the user to test thi