Python requests.status_codes() Examples
The following are 2
code examples of requests.status_codes().
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
requests
, or try the search function
.
Example #1
Source File: test_resources_available.py From cloudify-manager with Apache License 2.0 | 6 votes |
def test_resources_available(self): container_ip = self.get_manager_ip() blueprint_id = 'b{0}'.format(uuid.uuid4()) blueprint_name = 'empty_blueprint.yaml' blueprint_path = resource('dsl/{0}'.format(blueprint_name)) self.client.blueprints.upload(blueprint_path, entity_id=blueprint_id) invalid_resource_url = 'https://{0}:{1}/resources/blueprints/{1}/{2}' \ .format(container_ip, 53229, blueprint_id) try: result = requests.head(invalid_resource_url) self.assertEqual( result.status_code, requests.status_codes.codes.not_found, "Resources are available through port 53229.") except ConnectionError: pass
Example #2
Source File: test_resources_available.py From cloudify-manager with Apache License 2.0 | 6 votes |
def test_resources_access(self): self.client.blueprints.upload(resource('dsl/empty_blueprint.yaml'), entity_id='blu') # admin can the blueprint admin_headers = self.client._client.headers self._assert_request_status_code( headers=admin_headers, path='/blueprints/default_tenant/blu/empty_blueprint.yaml', expected_status_code=requests.status_codes.codes.ok) # invalid authentication self._assert_request_status_code( headers=get_auth_header('bla', 'bla'), path='/blueprints/default_tenant/blu/empty_blueprint.yaml', expected_status_code=requests.status_codes.codes.unauthorized) # trying to access non-existing resource self._assert_request_status_code( headers=admin_headers, path='/blueprints/default_tenant/blu/non_existing_resource', expected_status_code=requests.status_codes.codes.not_found)