def testShouldNotGetStuckOnTheCallToConnectionDotRequest(self): """Resuming session will get expected response from connection""" source = SessionScreenscrapeSource() class StubConnection (object): def request(self, url, method, data, headers): self.requestheaders = headers from StringIO import StringIO response = StringIO('Body Text') response.getheaders = lambda: {'h1':1,'h2':2} return response StubConnection = Stub(PcsConnection)(StubConnection) conn = StubConnection() body, headers = source.reconnect_to_pcs(conn, '1234567')
def testShouldSendCookiesToAndReturnExpectedBodyTextFromConnectionWhenReconnectingToSession(self): """Resuming session will get expected response from connection""" source = SessionScreenscrapeSource() class StubConnection (object): def request(self, url, method, data, headers): self.requestheaders = headers from StringIO import StringIO response = StringIO('Body Text') response.getheaders = lambda: {'h1':1,'h2':2} return response StubConnection = Stub(PcsConnection)(StubConnection) conn = StubConnection() body, headers = source.reconnect_to_pcs(conn, '1234567') self.assertEqual(conn.requestheaders, {'Cookie':'sid=1234567'}) self.assertEqual(body, 'Body Text') self.assertEqual(headers, {'h1':1,'h2':2})