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:
SeongSoo Cho 2019-11-07 15:32:21 +08:00
parent b96dd047ad
commit 7f6b09dc93
2 changed files with 23 additions and 0 deletions

View File

@ -384,6 +384,21 @@ class InternalClient(object):
return self._iter_items(path, marker, end_marker, prefix,
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(
self, account, acceptable_statuses=(2, HTTP_NOT_FOUND)):
"""

View File

@ -940,6 +940,14 @@ class TestInternalClient(unittest.TestCase):
ret_items.append(container)
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):
class Response(object):
def __init__(self, containers, objects):