Python six.moves.http_client.METHOD_NOT_ALLOWED Examples
The following are 7
code examples of six.moves.http_client.METHOD_NOT_ALLOWED().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
six.moves.http_client
, or try the search function
.
Example #1
Source File: test_notifications.py From masakari with Apache License 2.0 | 5 votes |
def test_delete_and_update_notification(self, method, mock_client): url = '/v1/notifications/%s' % uuidsentinel.fake_notification fake_req = fakes.HTTPRequest.blank(url, use_admin_context=True) fake_req.headers['Content-Type'] = 'application/json' fake_req.method = method resp = fake_req.get_response(self.app) self.assertEqual(http.METHOD_NOT_ALLOWED, resp.status_code)
Example #2
Source File: test_controller.py From tacker with Apache License 2.0 | 5 votes |
def test_create_not_allowed_http_method(self, method): """Wrong HTTP method""" body = {"vnfdId": uuidsentinel.vnfd_id} req = fake_request.HTTPRequest.blank('/vnf_instances') req.body = jsonutils.dump_as_bytes(body) req.headers['Content-Type'] = 'application/json' req.method = method resp = req.get_response(self.app) self.assertEqual(http_client.METHOD_NOT_ALLOWED, resp.status_code)
Example #3
Source File: test_controller.py From tacker with Apache License 2.0 | 5 votes |
def test_instantiate_invalid_http_method(self, method): # Wrong HTTP method body = fakes.get_vnf_instantiation_request_body() req = fake_request.HTTPRequest.blank( '/vnf_instances/29c770a3-02bc-4dfc-b4be-eb173ac00567/instantiate') req.body = jsonutils.dump_as_bytes(body) req.headers['Content-Type'] = 'application/json' req.method = method resp = req.get_response(self.app) self.assertEqual(http_client.METHOD_NOT_ALLOWED, resp.status_code)
Example #4
Source File: test_controller.py From tacker with Apache License 2.0 | 5 votes |
def test_show_invalid_http_method(self, http_method): req = fake_request.HTTPRequest.blank( '/vnf_instances/%s' % constants.UUID) req.headers['Content-Type'] = 'application/json' req.method = http_method resp = req.get_response(self.app) self.assertEqual(http_client.METHOD_NOT_ALLOWED, resp.status_code)
Example #5
Source File: test_controller.py From tacker with Apache License 2.0 | 5 votes |
def test_terminate_invalid_http_method(self, method): # Wrong HTTP method body = {'terminationType': 'GRACEFUL', 'gracefulTerminationTimeout': 10} req = fake_request.HTTPRequest.blank( '/vnf_instances/%s/terminate' % uuidsentinel.vnf_instance_id) req.body = jsonutils.dump_as_bytes(body) req.headers['Content-Type'] = 'application/json' req.method = method resp = req.get_response(self.app) self.assertEqual(http_client.METHOD_NOT_ALLOWED, resp.status_code)
Example #6
Source File: test_controller.py From tacker with Apache License 2.0 | 5 votes |
def test_heal_invalid_http_method(self, method): body = {} req = fake_request.HTTPRequest.blank( '/vnf_instances/%s/heal' % uuidsentinel.vnf_instance_id) req.body = jsonutils.dump_as_bytes(body) req.headers['Content-Type'] = 'application/json' req.method = method resp = req.get_response(self.app) self.assertEqual(http_client.METHOD_NOT_ALLOWED, resp.status_code)
Example #7
Source File: client.py From jarvis with GNU General Public License v2.0 | 5 votes |
def _do_revoke(self, http, token): """Revokes this credential and deletes the stored copy (if it exists). Args: http: an object to be used to make HTTP requests. token: A string used as the token to be revoked. Can be either an access_token or refresh_token. Raises: TokenRevokeError: If the revoke request does not return with a 200 OK. """ logger.info('Revoking token') query_params = {'token': token} token_revoke_uri = _helpers.update_query_params( self.revoke_uri, query_params) resp, content = transport.request(http, token_revoke_uri) if resp.status == http_client.METHOD_NOT_ALLOWED: body = urllib.parse.urlencode(query_params) resp, content = transport.request(http, token_revoke_uri, method='POST', body=body) if resp.status == http_client.OK: self.invalid = True else: error_msg = 'Invalid response {0}.'.format(resp.status) try: d = json.loads(_helpers._from_bytes(content)) if 'error' in d: error_msg = d['error'] except (TypeError, ValueError): pass raise TokenRevokeError(error_msg) if self.store: self.store.delete()