summaryrefslogtreecommitdiff
path: root/openstackclient
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-11-05 09:24:49 +0000
committerGerrit Code Review <review@openstack.org>2022-11-05 09:24:49 +0000
commitb0b47472d81b4f29ed70a0755434ac9e4a4b9f62 (patch)
tree7a515b3fdcd9dff2e9f819dc57de8381e0c35121 /openstackclient
parentae5f20c1ab58a49d951b3df696b98c4f10488650 (diff)
parent2da4aa99aaca3debcda1d046b7806a8f83ac8090 (diff)
downloadpython-openstackclient-b0b47472d81b4f29ed70a0755434ac9e4a4b9f62.tar.gz
Merge "quota: Fix issues with delete quota command"
Diffstat (limited to 'openstackclient')
-rw-r--r--openstackclient/common/quota.py6
-rw-r--r--openstackclient/tests/unit/common/test_quota.py27
2 files changed, 17 insertions, 16 deletions
diff --git a/openstackclient/common/quota.py b/openstackclient/common/quota.py
index 10f40a75..f2d097fc 100644
--- a/openstackclient/common/quota.py
+++ b/openstackclient/common/quota.py
@@ -972,12 +972,12 @@ class DeleteQuota(command.Command):
# compute quotas
if parsed_args.service in {'all', 'compute'}:
compute_client = self.app.client_manager.compute
- compute_client.quotas.delete(project)
+ compute_client.quotas.delete(project.id)
# volume quotas
if parsed_args.service in {'all', 'volume'}:
volume_client = self.app.client_manager.volume
- volume_client.quotas.delete(project)
+ volume_client.quotas.delete(project.id)
# network quotas (but only if we're not using nova-network, otherwise
# we already deleted the quotas in the compute step)
@@ -986,6 +986,6 @@ class DeleteQuota(command.Command):
and self.app.client_manager.is_network_endpoint_enabled()
):
network_client = self.app.client_manager.network
- network_client.quotas.delete(project)
+ network_client.delete_quota(project.id)
return None
diff --git a/openstackclient/tests/unit/common/test_quota.py b/openstackclient/tests/unit/common/test_quota.py
index 682799b3..f798137a 100644
--- a/openstackclient/tests/unit/common/test_quota.py
+++ b/openstackclient/tests/unit/common/test_quota.py
@@ -62,8 +62,8 @@ class TestQuota(compute_fakes.TestComputev2):
self.app.client_manager.volume.quota_classes
self.volume_quotas_class_mock.reset_mock()
- self.app.client_manager.network.quotas = mock.Mock()
- self.network_quotas_mock = self.app.client_manager.network.quotas
+ self.app.client_manager.network = mock.Mock()
+ self.network_mock = self.app.client_manager.network
self.app.client_manager.auth_ref = mock.Mock()
self.app.client_manager.auth_ref.service_catalog = mock.Mock()
@@ -660,7 +660,6 @@ class TestQuotaSet(TestQuota):
loaded=True,
)
- self.network_mock = self.app.client_manager.network
self.network_mock.update_quota = mock.Mock()
self.cmd = quota.SetQuota(self.app, None)
@@ -1272,6 +1271,8 @@ class TestQuotaDelete(TestQuota):
def setUp(self):
super().setUp()
+ self.network_mock.delete_quota = mock.Mock()
+
self.cmd = quota.DeleteQuota(self.app, None)
def test_delete(self):
@@ -1291,13 +1292,13 @@ class TestQuotaDelete(TestQuota):
self.assertIsNone(result)
self.projects_mock.get.assert_called_once_with(self.projects[0].id)
self.compute_quotas_mock.delete.assert_called_once_with(
- self.projects[0],
+ self.projects[0].id,
)
self.volume_quotas_mock.delete.assert_called_once_with(
- self.projects[0],
+ self.projects[0].id,
)
- self.network_quotas_mock.delete.assert_called_once_with(
- self.projects[0],
+ self.network_mock.delete_quota.assert_called_once_with(
+ self.projects[0].id,
)
def test_delete__compute(self):
@@ -1318,10 +1319,10 @@ class TestQuotaDelete(TestQuota):
self.assertIsNone(result)
self.projects_mock.get.assert_called_once_with(self.projects[0].id)
self.compute_quotas_mock.delete.assert_called_once_with(
- self.projects[0],
+ self.projects[0].id,
)
self.volume_quotas_mock.delete.assert_not_called()
- self.network_quotas_mock.delete.assert_not_called()
+ self.network_mock.delete_quota.assert_not_called()
def test_delete__volume(self):
"""Delete volume quotas only"""
@@ -1342,9 +1343,9 @@ class TestQuotaDelete(TestQuota):
self.projects_mock.get.assert_called_once_with(self.projects[0].id)
self.compute_quotas_mock.delete.assert_not_called()
self.volume_quotas_mock.delete.assert_called_once_with(
- self.projects[0],
+ self.projects[0].id,
)
- self.network_quotas_mock.delete.assert_not_called()
+ self.network_mock.delete_quota.assert_not_called()
def test_delete__network(self):
"""Delete network quotas only"""
@@ -1365,6 +1366,6 @@ class TestQuotaDelete(TestQuota):
self.projects_mock.get.assert_called_once_with(self.projects[0].id)
self.compute_quotas_mock.delete.assert_not_called()
self.volume_quotas_mock.delete.assert_not_called()
- self.network_quotas_mock.delete.assert_called_once_with(
- self.projects[0],
+ self.network_mock.delete_quota.assert_called_once_with(
+ self.projects[0].id,
)