Example #1
0
 def test_user_proxy(self):
     request(self.method, sentinel.url,
             sentinel.username, sentinel.password,
             kwarg=sentinel.kwvalue)
     self.method.assert_called_once_with(sentinel.url,
                                         auth=(sentinel.username,
                                               sentinel.password),
                                         kwarg=sentinel.kwvalue)
Example #2
0
 def test_insecure_platform_message_is_printed(self):
     _reset_platform_warning()
     self.method.side_effect = self._warn_and_respond(InsecurePlatformWarning)
     buff = six.StringIO()
     sys.stdout = buff
     try:
         request(self.method, sentinel.url)
     finally:
         sys.stdout = sys.__stdout__
     self.assertIn('Got an InsecurePlatformWarning. Upgrade python to 2.7.9 or better to remove.',
                   buff.getvalue())
Example #3
0
 def test_insecure_platform_is_supresed(self):
     _reset_platform_warning()
     self.method.side_effect = self._warn_and_respond(InsecurePlatformWarning)
     with warnings.catch_warnings(record=True) as warns:
         response = request(self.method, sentinel.url)
         eq_(warns, [])
         eq_(response, self.response)
Example #4
0
 def test_not_all_warnings_are__supresed(self):
     _reset_platform_warning()
     self.method.side_effect = self._warn_and_respond(Warning, 'warning_message')
     with warnings.catch_warnings(record=True) as warns:
         response = request(self.method, sentinel.url)
         eq_(len(warns), 1)
         self.assertIn('warning_message', str(warns[0]))
         eq_(response, self.response)
Example #5
0
 def test_exception_contains_response(self):
     self.response.status_code = 500
     try:
         request(self.method, sentinel.url)
     except NotOkResponse as err:
         eq_(err.response, self.response)
Example #6
0
 def test_server_error_fails(self):
     self.response.status_code = 500
     request(self.method, sentinel.url)
Example #7
0
 def test_not_found_fails(self):
     self.response.status_code = 404
     request(self.method, sentinel.url)
Example #8
0
 def test_no_user_proxy(self):
     response = request(self.method, sentinel.url,
                        kwarg=sentinel.kwvalue)
     self.method.assert_called_once_with(sentinel.url,
                                         kwarg=sentinel.kwvalue)
     eq_(response, self.response)