Ejemplo n.º 1
0
 def test_050(self):
     """HTTP GET against http://some.bogus.address/ raises ConnectionError"""
     s = session.Session('http://some.bogus.address')
     logger = logging.getLogger()
     with d1_common.logging_context.LoggingContext(logger):
         logger.setLevel(logging.ERROR)
         self.assertRaises(requests.exceptions.ConnectionError, s.GET, '/')
Ejemplo n.º 2
0
 def _post(self, query_dict, header_dict, body):
   mock_post.add_callback(d1_test.d1_test_case.MOCK_MN_BASE_URL)
   s = session.Session(
     d1_test.d1_test_case.MOCK_MN_BASE_URL, query={
       'default_query': 'test',
     }
   )
   return s.POST(['post'], query=query_dict, headers=header_dict, data=body)
Ejemplo n.º 3
0
 def _post(self, query_dict, header_dict, body):
     s = session.Session(shared_settings.MN_RESPONSES_URL,
                         query={
                             'default_query': 'test',
                         })
     return s.POST(['post'],
                   query=query_dict,
                   headers=header_dict,
                   data=body)
Ejemplo n.º 4
0
 def test_1070(self):
   """cURL command line retains query parameters and headers"""
   query_dict = {'abcd': '1234', 'efgh': '5678'}
   header_dict = {'ijkl': '9876', 'mnop': '5432'}
   s = session.Session(d1_test.d1_test_case.MOCK_MN_BASE_URL)
   curl_str = s.get_curl_command_line(
     'POST',
     'http://some.bogus.address',
     query=query_dict,
     headers=header_dict,
   )
   d1_test.sample.assert_equals(curl_str, 'curl_command_line')
Ejemplo n.º 5
0
 def test_1070(self):
     """cURL command line retains query parameters and headers"""
     query_dict = {'abcd': '1234', 'efgh': '5678'}
     header_dict = {'ijkl': '9876', 'mnop': '5432'}
     s = session.Session(d1_test.d1_test_case.MOCK_BASE_URL)
     curl_str = s.get_curl_command_line(
         'POST',
         'http://some.bogus.address',
         query=query_dict,
         headers=header_dict,
     )
     assert curl_str == \
       'curl -X POST -H "ijkl: 9876" -H "mnop: 5432" http://some.bogus.address?abcd=1234&efgh=5678'
Ejemplo n.º 6
0
 def test_200(self):
     """cURL command line retains query parameters and headers"""
     query_dict = {'abcd': '1234', 'efgh': '5678'}
     header_dict = {'ijkl': '9876', 'mnop': '5432'}
     s = session.Session(shared_settings.MN_RESPONSES_URL)
     curl_str = s.get_curl_command_line(
         'POST',
         'http://some.bogus.address',
         query=query_dict,
         headers=header_dict,
     )
     self.assertEqual(
         curl_str,
         'curl -X POST -H "ijkl: 9876" -H "mnop: 5432" http://some.bogus.address?abcd=1234&efgh=5678',
     )
Ejemplo n.º 7
0
 def _post_fields(self, fields_dict):
   mock_post.add_callback(d1_test.d1_test_case.MOCK_MN_BASE_URL)
   s = session.Session(d1_test.d1_test_case.MOCK_MN_BASE_URL)
   return s.POST(['post'], fields=fields_dict)
Ejemplo n.º 8
0
 def _get_response(self, pid, header_dict=None):
   mock_get.add_callback(d1_test.d1_test_case.MOCK_MN_BASE_URL)
   s = session.Session(d1_test.d1_test_case.MOCK_MN_BASE_URL)
   return s.GET(['object', pid], headers=header_dict or {})
Ejemplo n.º 9
0
 def _get_hash(self, pid):
   mock_get.add_callback(d1_test.d1_test_case.MOCK_MN_BASE_URL)
   s = session.Session(d1_test.d1_test_case.MOCK_MN_BASE_URL)
   response = s.GET(['object', pid])
   return hashlib.sha1(response.content).hexdigest()
Ejemplo n.º 10
0
 def _post_fields(self, fields_dict):
     s = session.Session(shared_settings.MN_RESPONSES_URL)
     return s.POST(['post'], fields=fields_dict)
Ejemplo n.º 11
0
 def _get_response(self, pid):
     s = session.Session(shared_settings.MN_RESPONSES_URL)
     return s.GET(['object', pid])
Ejemplo n.º 12
0
 def _get_hash(self, pid):
     s = session.Session(shared_settings.MN_RESPONSES_URL)
     response = s.GET(['object', pid])
     return hashlib.sha1(response.content).hexdigest()