I’m trying to test that a UserProfile model is created as a new User is registered in django_authopenid.
I don’t understand how to add the Openid session data to the POST.
class UserTestCAse(TestCase):
def test_register_should_create_UserProfile(self):
from django.test.client import Client
c = Client()
response = c.post('/account/register/', {u'username': [u'john'], u'email': [u'john@beatles.com'], u'bnewaccount': [u'Signup']},)
self.assertEqual(response.status_code, 302)
user = User.objects.get( username ='john')
self.assertTrue(user.get_profile())
Apparently, adding session data to the django.test.client.Client without using Client.login() is not so easy.
The easiest solution was to create a new RequestFactory class so I could build a Request with the OpenID session object.
I used the RequestFactory method like this: