From 7f6b09dc930706d63a943dc239dff84ddae52014 Mon Sep 17 00:00:00 2001 From: SeongSoo Cho Date: Thu, 7 Nov 2019 15:32:21 +0800 Subject: [PATCH] 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 --- swift/common/internal_client.py | 15 +++++++++++++++ test/unit/common/test_internal_client.py | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/swift/common/internal_client.py b/swift/common/internal_client.py index 782aae6bd6..0e2c4ab449 100644 --- a/swift/common/internal_client.py +++ b/swift/common/internal_client.py @@ -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)): """ diff --git a/test/unit/common/test_internal_client.py b/test/unit/common/test_internal_client.py index 158841a1c6..524be1054d 100644 --- a/test/unit/common/test_internal_client.py +++ b/test/unit/common/test_internal_client.py @@ -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):