def test_unintegrated(self): """Deauthorize view should short-circuit if user isn't integrated.""" self.hvuser.delete() response = self._mock_connection_get() redirect_url = utils.get_setting('HEALTHVAULT_DEAUTHORIZE_REDIRECT') self.assertRedirectsNoFollow(response, redirect_url) self.assertEqual(HealthVaultUser.objects.count(), 0)
def test_anonymous(self): """User must be logged in to access Error view.""" self.client.logout() response = self._get() login_url = utils.get_setting('LOGIN_URL') self.assertRedirectsNoFollow(response, login_url, use_params=False) self.assertFalse(NEXT_SESSION_KEY in self.client.session)
def test_anonymous(self): """User must be logged in to access Deauthorize view.""" self.client.logout() response = self._get() login_url = utils.get_setting('LOGIN_URL') self.assertRedirectsNoFollow(response, login_url, use_params=False) self.assertEqual(HealthVaultUser.objects.count(), 1)
def test_unintegrated(self): """Complete view should store user's access credentials.""" response = self._mock_connection_get() redirect_url = utils.get_setting('HEALTHVAULT_AUTHORIZE_REDIRECT') self.assertRedirectsNoFollow(response, redirect_url) self.assertEqual(HealthVaultUser.objects.count(), 1) hvuser = HealthVaultUser.objects.get() self.assertEqual(hvuser.token, self.token) self.assertEqual(hvuser.record_id, self.record_id)
def test_integrated(self): """Complete view should overwrite any existing credentials.""" hvuser = self.create_healthvault_user(user=self.user) response = self._mock_connection_get() redirect_url = utils.get_setting('HEALTHVAULT_AUTHORIZE_REDIRECT') self.assertRedirectsNoFollow(response, redirect_url) self.assertEqual(HealthVaultUser.objects.count(), 1) hvuser = HealthVaultUser.objects.get() self.assertEqual(hvuser.token, self.token) self.assertEqual(hvuser.record_id, self.record_id)
def test_integrated(self): """Complete view should redirect.""" response = self._mock_connection_get() redirect_url = utils.get_setting('HEALTHVAULT_DEAUTHORIZE_REDIRECT') self.assertRedirectsNoFollow(response, redirect_url) self.assertEqual(HealthVaultUser.objects.count(), 0)
def test_unintegrated(self): """Should redirect to denial URL.""" response = self._mock_connection_get() redirect_url = utils.get_setting('HEALTHVAULT_DENIED_REDIRECT') self.assertRedirectsNoFollow(response, redirect_url) self.assertEqual(HealthVaultUser.objects.count(), 0)