def test_domain_doesnt_allow_anonymous(self): response = domain(self.request_get, settings.TEST_DOMAIN) self.assertEqual(response.status_code, 302) self.assertTrue(isinstance(response, HttpResponseRedirect)) self.assertEqual(response.url, '/') response = domain(self.request_post, settings.TEST_DOMAIN) self.assertEqual(response.status_code, 302) self.assertTrue(isinstance(response, HttpResponseRedirect)) self.assertEqual(response.url, '/')
def test_domain_handles_logged_in_user(self): self.request_get.session = { 'username': settings.TEST_USER, 'password': settings.TEST_PASSWORD, 'api_url': settings.DEFAULT_API_URL} response = domain(self.request_get, settings.TEST_DOMAIN) self.request_get.session = {} self.assertEqual(response.status_code, 200) self.assertContains(response, '<td>{id}</td>'.format(id=settings.TEST_DOMAIN))