コード例 #1
0
 def setUp(self):
     self.context = open_dependency_context()
     requests_stub = EndlessFake(pattern_obj=requests)
     session_stub = EndlessFake(pattern_obj=requests.sessions.Session())
     self.send_spy = FunctionSpy(return_value=EndlessFake())
     session_stub.send = self.send_spy
     requests_stub.Session = lambda *a, **k: session_stub
     self.context.inject(requests, requests_stub)
コード例 #2
0
 def test_enabled_in_session_by_default(self):
     requests_stub = EndlessFake()
     self.context.inject(requests, requests_stub)
     spy = MasterSpy(EndlessFake())
     requests_stub.Session = lambda *a, **k: spy
     client = HttpClient()
     client.enable_cookies()
     client.get("http://spam")
     args, kwargs = spy.last_call_to("send")
     expect(kwargs).to(have_keys(verify=True))
コード例 #3
0
 def test_disabled_in_session_when_configured(self):
     self.context.set_env(HTTPS_VERIFY_CERTS="FAlSe")
     requests_stub = EndlessFake()
     self.context.inject(requests, requests_stub)
     spy = MasterSpy(EndlessFake())
     requests_stub.Session = lambda *a, **k: spy
     client = HttpClient()
     client.enable_cookies()
     client.get("http://spam")
     args, kwargs = spy.last_call_to("send")
     expect(kwargs).to(have_keys(verify=False))