def test_alarms_doesnt_allow_anonymous(self): response = alarms(self.request_get) self.assertEqual(response.status_code, 302) self.assertTrue(isinstance(response, HttpResponseRedirect)) self.assertEqual(response.url, '/') response = alarms(self.request_post) self.assertEqual(response.status_code, 302) self.assertTrue(isinstance(response, HttpResponseRedirect)) self.assertEqual(response.url, '/')
def test_alarms_handles_logged_in_user(self): self.request_get.session = { 'username': settings.TEST_USER, 'password': settings.TEST_PASSWORD, 'api_url': settings.DEFAULT_API_URL} response = alarms(self.request_get) self.request_get.session = {} self.assertEqual(response.status_code, 200) self.assertContains(response, '<form class="form-horizontal" role="form" method="POST">')