def test_basic(self): http_client = Client() client = RichClient(http_client) session = client.session(Request.new(self.get_url('/'))) self.assertFalse(session.done) response = yield session.fetch() self.assertEqual(200, response.status_code) self.assertTrue(session.done)
def test_bad_redirect(self): http_client = Client() client = RichClient(http_client) session = client.session(Request.new(self.get_url('/bad_redirect'))) while not session.done: try: yield session.fetch() except ProtocolError: return else: self.fail()
def test_redirect(self): http_client = Client() client = RichClient(http_client) session = client.session(Request.new(self.get_url('/redirect'))) status_codes = [] while not session.done: response = yield session.fetch() if not status_codes: self.assertEqual( RichClientResponseType.redirect, session.response_type) status_codes.append(response.status_code) self.assertEqual([301, 200], status_codes) self.assertTrue(session.done) self.assertEqual(RichClientResponseType.normal, session.response_type)
def test_redirect(self): http_client = Client() client = RichClient(http_client) session = client.session(Request.new(self.get_url('/redirect'))) status_codes = [] while not session.done: response = yield session.fetch() if not status_codes: self.assertEqual(RichClientResponseType.redirect, session.response_type) status_codes.append(response.status_code) self.assertEqual([301, 200], status_codes) self.assertTrue(session.done) self.assertEqual(RichClientResponseType.normal, session.response_type)