Here are the examples of the python api requests.codes.no_content taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
18 Examples
3
Example 1
Project: rides-python-sdk Source File: test_client.py
@uber_vcr.use_cassette()
def test_update_ride_destination(authorized_sandbox_client):
"""Test to update the trip destination."""
response = authorized_sandbox_client.update_ride(
RIDE_ID,
end_latitude=UPDATE_LAT,
end_longitude=UPDATE_LNG,
)
assert response.status_code == codes.no_content
3
Example 2
Project: rides-python-sdk Source File: test_client.py
@uber_vcr.use_cassette()
def test_update_ride_destination_with_places(authorized_sandbox_client):
"""Test to update the trip destination with a place ID."""
response = authorized_sandbox_client.update_ride(
RIDE_ID,
end_place_id='work',
)
assert response.status_code == codes.no_content
3
Example 3
Project: rides-python-sdk Source File: test_client.py
@uber_vcr.use_cassette()
def test_update_sandbox_ride(authorized_sandbox_client):
"""Test to update sandbox ride status with access token."""
response = authorized_sandbox_client.update_sandbox_ride(
ride_id=RIDE_ID,
new_status='accepted',
)
assert response.status_code == codes.no_content
3
Example 4
Project: rides-python-sdk Source File: test_client.py
@uber_vcr.use_cassette()
def test_update_sandbox_product(authorized_sandbox_client):
"""Test to update sandbox ride status with access token."""
response = authorized_sandbox_client.update_sandbox_product(
product_id=PRODUCT_ID,
surge_multiplier=2,
)
assert response.status_code == codes.no_content
3
Example 5
Project: bravado Source File: client_test.py
@httpretty.activate
def test_post_binary_data(self):
httpretty.register_uri(
httpretty.POST, 'http://swagger.py/swagger-test/pet/1234/vaccine',
status=requests.codes.no_content)
temporary_file = tempfile.TemporaryFile()
temporary_file.write('\xff\xd8')
temporary_file.seek(0)
resp = self.uut.pet.postVaccine(
vaccineFile=temporary_file, petId=1234).result()
self.assertEqual(None, resp)
3
Example 6
@httpretty.activate
def test_delete(self):
httpretty.register_uri(
httpretty.DELETE, "http://swagger.py/swagger-test/pet/1234",
status=requests.codes.no_content)
resp = self.uut.pet.deletePet(petId=1234).result()
self.assertEqual(None, resp)
3
Example 7
@httpretty.activate
def test_delete(self):
httpretty.register_uri(
httpretty.DELETE, "http://swagger.py/swagger-test/pet/1234",
status=requests.codes.no_content)
resp = self.uut.pet.deletePet(petId=1234)
self.assertEqual(requests.codes.no_content, resp.status_code)
self.assertEqual('', resp.content)
3
Example 8
Project: pysensu Source File: pysensu.py
def delete_stash(self, client, check=None):
if check:
r = self._api_call("{}/stashes/{}/{}".format(self.api_url, client, check), "delete")
else:
r = self._api_call("{}/stashes/{}".format(self.api_url, client), "delete")
if r.status_code != requests.codes.no_content:
raise ValueError("Error deleting stash ({})".format(r.status_code))
3
Example 9
def test_delete_network_postcommit(self):
self._test_delete_resource_postcommit(odl_const.ODL_NETWORK,
requests.codes.no_content)
self._test_delete_resource_postcommit(odl_const.ODL_NETWORK,
requests.codes.not_found)
for status_code in (requests.codes.unauthorized,
requests.codes.conflict):
self._test_delete_resource_postcommit(
odl_const.ODL_NETWORK, status_code,
requests.exceptions.HTTPError)
3
Example 10
def test_delete_subnet_postcommit(self):
self._test_delete_resource_postcommit(odl_const.ODL_SUBNET,
requests.codes.no_content)
self._test_delete_resource_postcommit(odl_const.ODL_SUBNET,
requests.codes.not_found)
for status_code in (requests.codes.unauthorized,
requests.codes.conflict,
requests.codes.not_implemented):
self._test_delete_resource_postcommit(
odl_const.ODL_SUBNET, status_code,
requests.exceptions.HTTPError)
3
Example 11
def test_delete_port_postcommit(self):
self._test_delete_resource_postcommit(odl_const.ODL_PORT,
requests.codes.no_content)
self._test_delete_resource_postcommit(odl_const.ODL_PORT,
requests.codes.not_found)
for status_code in (requests.codes.unauthorized,
requests.codes.forbidden,
requests.codes.not_implemented):
self._test_delete_resource_postcommit(
odl_const.ODL_PORT, status_code,
requests.exceptions.HTTPError)
3
Example 12
Project: python-glanceclient Source File: images.py
def data(self, image_id, do_checksum=True):
"""Retrieve data of an image.
:param image_id: ID of the image to download.
:param do_checksum: Enable/disable checksum validation.
:returns: An iterable body or None
"""
url = '/v2/images/%s/file' % image_id
resp, body = self.http_client.get(url)
if resp.status_code == codes.no_content:
return None
checksum = resp.headers.get('content-md5', None)
content_length = int(resp.headers.get('content-length', 0))
if do_checksum and checksum is not None:
body = utils.integrity_iter(body, checksum)
return utils.IterableWithLength(body, content_length)
3
Example 13
def serve(self, method, *args, **kwargs):
"""Serve a single URL for current test.
:param method: HTTP method. httpretty.{GET,PUT,POST,DELETE}.
:param args: URL path segments.
:param kwargs: See httpretty.register_uri()
"""
url = self.build_url(*args)
if kwargs.get('body') is None and 'status' not in kwargs:
kwargs['status'] = requests.codes.no_content
httpretty.register_uri(method, url,
content_type="application/json",
**kwargs)
0
Example 14
Project: rides-python-sdk Source File: test_client.py
@uber_vcr.use_cassette()
def test_cancel_ride(authorized_sandbox_client):
"""Test to cancel ride with access token."""
response = authorized_sandbox_client.cancel_ride(RIDE_ID)
assert response.status_code == codes.no_content
0
Example 15
Project: rides-python-sdk Source File: test_client.py
@uber_vcr.use_cassette()
def test_cancel_current_ride(authorized_sandbox_client):
"""Test to cancel the current ride with access token."""
response = authorized_sandbox_client.cancel_current_ride()
assert response.status_code == codes.no_content
0
Example 16
Project: pyvcloud Source File: vapp.py
def customize_on_next_poweron(self):
"""
Force the guest OS customization script to be run for the first VM in the vApp.
A customization script must have been previously associated with the VM
using the pyvcloud customize_guest_os method or using the vCD console
The VMware tools must be installed in the Guest OS.
:return: (bool) True if the request was accepted, False otherwise. If False an error level log message is generated.
"""
vm = self._get_vms()[0]
link = filter(lambda link: link.get_rel() == "customizeAtNextPowerOn",
vm.get_Link())
if link:
self.response = Http.post(link[0].get_href(), data=None,
verify=self.verify, headers=self.headers,
logger=self.logger)
if self.response.status_code == requests.codes.no_content:
return True
Log.error(self.logger, "link not found")
return False
0
Example 17
def _request(self, method, resource, **kwargs):
"""Send a service request.
:param method: The HTTP method.
:param resource: The URI resource.
:param kwargs: Request keyword-arguments.
:raises: `RequestException` if there was a problem with the request.
"""
url = urljoin(self.url, resource)
if "data" in kwargs:
kwargs["data"] = dumps(kwargs["data"])
response = self.get_response(method, url, **kwargs)
response.raise_for_status()
if response.status_code == codes.no_content:
ret_val = None
else:
ret_val = response.json()
return ret_val
0
Example 18
def promote(client, resp, operation_json):
"""Promote a response from the request's HTTP response to a first class
object.
:param client: ARI client.
:type client: client.Client
:param resp: HTTP resonse.
:type resp: requests.Response
:param operation_json: JSON model from Swagger API.
:type operation_json: dict
:return:
"""
resp.raise_for_status()
response_class = operation_json['responseClass']
is_list = False
m = re.match('''List\[(.*)\]''', response_class)
if m:
response_class = m.group(1)
is_list = True
factory = CLASS_MAP.get(response_class)
if factory:
resp_json = resp.json()
if is_list:
return [factory(client, obj) for obj in resp_json]
return factory(client, resp_json)
if resp.status_code == requests.codes.no_content:
return None
log.info("No mapping for %s; returning JSON" % response_class)
return resp.json()