Exemplo n.º 1
0
 def it_handles_updating_token_with_charset(self, response, token_response_with_charset):
     returns = [token_response_with_charset, token_response_with_charset, response]
     h = RequestHandler("")
     h._send_request = Mock(side_effect=lambda *args: returns.pop(0))
     with patch("ubersmith.api.time") as time:
         time.sleep = lambda x: None
         assert self.test_data == h.process_request("uber.method_list").data
Exemplo n.º 2
0
 def it_raises_updating_token_after_3_tries(self, response, token_response):
     returns = [token_response, token_response, token_response, response]
     h = RequestHandler("")
     h._send_request = Mock(side_effect=lambda *args: returns.pop(0))
     with patch("ubersmith.api.time") as time:
         time.sleep = lambda x: None
         with pytest.raises(UpdatingTokenResponse):
             h.process_request("uber.method_list")
Exemplo n.º 3
0
 def it_handles_updating_token(self, response, token_response):
     returns = [
         token_response,
         token_response,
         response,
     ]
     h = RequestHandler('')
     h._send_request = Mock(side_effect=lambda *args: returns.pop(0))
     with patch('ubersmith.api.time') as time:
         time.sleep = lambda x: None
         assert self.test_data == h.process_request('uber.method_list').data
Exemplo n.º 4
0
 def it_handles_updating_token(self, response, token_response):
     returns = [
         token_response,
         token_response,
         response,
     ]
     h = RequestHandler('')
     h._send_request = Mock(side_effect=lambda *args: returns.pop(0))
     with patch('ubersmith.api.time') as time:
         time.sleep = lambda x: None
         assert self.test_data == h.process_request('uber.method_list').data
Exemplo n.º 5
0
 def it_raises_updating_token_after_3_tries(self, response, token_response):
     returns = [
         token_response,
         token_response,
         token_response,
         response,
     ]
     h = RequestHandler('')
     h._send_request = Mock(side_effect=lambda *args: returns.pop(0))
     with patch('ubersmith.api.time') as time:
         time.sleep = lambda x: None
         with pytest.raises(UpdatingTokenResponse):
             h.process_request('uber.method_list')
Exemplo n.º 6
0
 def it_handles_normal_responses(self, response):
     h = RequestHandler('')
     h._send_request = Mock(return_value=response)
     assert self.test_data == h.process_request('uber.method_list').data
Exemplo n.º 7
0
 def it_uses_passed_session(self):
     session = Mock()
     h = RequestHandler('', session=session)
     h._send_request('uber.method_list', {})
     assert session.post.called
Exemplo n.º 8
0
 def it_raises_maintenance_response(self, maintenance_response):
     h = RequestHandler('')
     h._send_request = Mock(return_value=maintenance_response)
     with pytest.raises(MaintenanceResponse):
         h.process_request('uber.method_list')
Exemplo n.º 9
0
 def it_handles_normal_responses(self, response):
     h = RequestHandler('')
     h._send_request = Mock(return_value=response)
     assert self.test_data == h.process_request('uber.method_list').data
Exemplo n.º 10
0
 def it_raises_maintenance_response(self, maintenance_response):
     h = RequestHandler('')
     h._send_request = Mock(return_value=maintenance_response)
     with pytest.raises(MaintenanceResponse):
         h.process_request('uber.method_list')
Exemplo n.º 11
0
 def it_uses_passed_session(self):
     session = Mock()
     h = RequestHandler("", session=session)
     h._send_request("uber.method_list", {})
     assert session.post.called