def test_domains_doesnt_allow_anonymous(self): response = domains(self.request_get) self.assertEqual(response.status_code, 302) self.assertTrue(isinstance(response, HttpResponseRedirect)) self.assertEqual(response.url, '/') response = domains(self.request_post) self.assertEqual(response.status_code, 302) self.assertTrue(isinstance(response, HttpResponseRedirect)) self.assertEqual(response.url, '/')
def test_domains_handles_logged_in_user(self): self.request_get.session = { 'username': settings.TEST_USER, 'password': settings.TEST_PASSWORD, 'api_url': settings.DEFAULT_API_URL} response = domains(self.request_get) self.request_get.session = {} self.assertEqual(response.status_code, 200) self.assertContains(response, NewDomainForm())