コード例 #1
0
ファイル: test_session.py プロジェクト: mjumbewu/pcs-api
 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')
コード例 #2
0
ファイル: test_session.py プロジェクト: mjumbewu/pcs-api
 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})