def test_whatnext(self): """Redirection after a successful openid login""" url = reverse("openid_whatnext") # No openid -> homepage response = self.client.get(url) self.assertRedirects(response, reverse("index")) # Anonymous user, openid -> signup factory = RequestFactory() request = prepare_request(factory.get(url)) response = openid_whatnext(request) self.assertEqual(response.status_code, 302) self.assertEqual(response["Location"], reverse("signup")) user = User.objects.create_user("testuser", "*****@*****.**", "pass") DjangoPerson.objects.create( user=user, country=Country.objects.get(pk=1), latitude=44, longitude=2, location_description="Somewhere" ) associate_openid(user, "http://foo.example.com/") # Anonymous user, openid + assoc. with an existing user -> profile response = openid_whatnext(request) self.assertEqual(response.status_code, 302) self.assertEqual(response["Location"], reverse("user_profile", args=["testuser"])) # Authenticated user -> openid associations self.client.login(username="******", password="******") request = prepare_request(factory.get(url)) request.session = self.client.session response = openid_whatnext(request) self.assertEqual(response.status_code, 302) self.assertEqual(response["Location"], reverse("openid_associations"))
def test_whatnext(self): """Redirection after a successful openid login""" url = reverse('openid_whatnext') # No openid -> homepage response = self.client.get(url) self.assertRedirects(response, reverse('index')) # Anonymous user, openid -> signup factory = RequestFactory() request = prepare_request(factory.get(url)) response = openid_whatnext(request) self.assertEqual(response.status_code, 302) self.assertEqual(response['Location'], reverse('signup')) user = User.objects.create_user('testuser', '*****@*****.**', 'pass') DjangoPerson.objects.create( user=user, country=Country.objects.get(pk=1), latitude=44, longitude=2, location_description='Somewhere', ) associate_openid(user, 'http://foo.example.com/') # Anonymous user, openid + assoc. with an existing user -> profile response = openid_whatnext(request) self.assertEqual(response.status_code, 302) self.assertEqual(response['Location'], reverse('user_profile', args=['testuser'])) # Authenticated user -> openid associations self.client.login(username='******', password='******') request = prepare_request(factory.get(url)) request.session = self.client.session response = openid_whatnext(request) self.assertEqual(response.status_code, 302) self.assertEqual(response['Location'], reverse('openid_associations'))