Add delete_account in InternalClient
Currently, The internal client module is missing a delete_account method. I added a delete_account in InternalClient Change-Id: I97cb090820b4099944ba49eaeb5b02f9bbcf1d58 Closes-Bug: #1680377
This commit is contained in:
@ -384,6 +384,21 @@ class InternalClient(object):
|
|||||||
return self._iter_items(path, marker, end_marker, prefix,
|
return self._iter_items(path, marker, end_marker, prefix,
|
||||||
acceptable_statuses)
|
acceptable_statuses)
|
||||||
|
|
||||||
|
def delete_account(self, account, acceptable_statuses=(2, HTTP_NOT_FOUND)):
|
||||||
|
"""
|
||||||
|
Deletes an account.
|
||||||
|
|
||||||
|
:param account: Account to delete.
|
||||||
|
:param acceptable_statuses: List of status for valid responses,
|
||||||
|
defaults to (2, HTTP_NOT_FOUND).
|
||||||
|
:raises UnexpectedResponse: Exception raised when requests fail
|
||||||
|
to get a response with an acceptable status
|
||||||
|
:raises Exception: Exception is raised when code fails in an
|
||||||
|
unexpected way.
|
||||||
|
"""
|
||||||
|
path = self.make_path(account)
|
||||||
|
self.make_request('DELETE', path, {}, acceptable_statuses)
|
||||||
|
|
||||||
def get_account_info(
|
def get_account_info(
|
||||||
self, account, acceptable_statuses=(2, HTTP_NOT_FOUND)):
|
self, account, acceptable_statuses=(2, HTTP_NOT_FOUND)):
|
||||||
"""
|
"""
|
||||||
|
@ -940,6 +940,14 @@ class TestInternalClient(unittest.TestCase):
|
|||||||
ret_items.append(container)
|
ret_items.append(container)
|
||||||
self.assertEqual(items, ret_items)
|
self.assertEqual(items, ret_items)
|
||||||
|
|
||||||
|
def test_delete_account(self):
|
||||||
|
account, container, obj = path_parts()
|
||||||
|
path = make_path_info(account)
|
||||||
|
client, app = get_client_app()
|
||||||
|
app.register('DELETE', path, swob.HTTPNoContent, {})
|
||||||
|
client.delete_account(account)
|
||||||
|
self.assertEqual(1, len(app._calls))
|
||||||
|
|
||||||
def test_get_account_info(self):
|
def test_get_account_info(self):
|
||||||
class Response(object):
|
class Response(object):
|
||||||
def __init__(self, containers, objects):
|
def __init__(self, containers, objects):
|
||||||
|
Reference in New Issue
Block a user