summaryrefslogtreecommitdiff
path: root/openstackclient/tests/common
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient/tests/common')
-rw-r--r--openstackclient/tests/common/test_quota.py25
-rw-r--r--openstackclient/tests/common/test_utils.py9
2 files changed, 27 insertions, 7 deletions
diff --git a/openstackclient/tests/common/test_quota.py b/openstackclient/tests/common/test_quota.py
index 485b8a8b..edf29c9b 100644
--- a/openstackclient/tests/common/test_quota.py
+++ b/openstackclient/tests/common/test_quota.py
@@ -214,13 +214,15 @@ class TestQuotaShow(TestQuota):
loaded=True,
)
- self.service_catalog_mock.get_endpoints.return_value = [
- fakes.FakeResource(
- None,
- copy.deepcopy(identity_fakes.ENDPOINT),
- loaded=True,
- )
- ]
+ fake_network_endpoint = fakes.FakeResource(
+ None,
+ copy.deepcopy(identity_fakes.ENDPOINT),
+ loaded=True,
+ )
+
+ self.service_catalog_mock.get_endpoints.return_value = {
+ 'network': fake_network_endpoint
+ }
self.quotas_class_mock.get.return_value = FakeQuotaResource(
None,
@@ -244,6 +246,8 @@ class TestQuotaShow(TestQuota):
endpoint=fakes.AUTH_URL,
token=fakes.AUTH_TOKEN,
)
+ self.network = self.app.client_manager.network
+ self.network.get_quota = mock.Mock(return_value=network_fakes.QUOTA)
self.cmd = quota.ShowQuota(self.app, None)
@@ -260,6 +264,9 @@ class TestQuotaShow(TestQuota):
self.cmd.take_action(parsed_args)
self.quotas_mock.get.assert_called_with(identity_fakes.project_id)
+ self.volume_quotas_mock.get.assert_called_with(
+ identity_fakes.project_id)
+ self.network.get_quota.assert_called_with(identity_fakes.project_id)
def test_quota_show_with_default(self):
arglist = [
@@ -276,6 +283,8 @@ class TestQuotaShow(TestQuota):
self.cmd.take_action(parsed_args)
self.quotas_mock.defaults.assert_called_with(identity_fakes.project_id)
+ self.volume_quotas_mock.defaults.assert_called_with(
+ identity_fakes.project_id)
def test_quota_show_with_class(self):
arglist = [
@@ -293,3 +302,5 @@ class TestQuotaShow(TestQuota):
self.quotas_class_mock.get.assert_called_with(
identity_fakes.project_id)
+ self.volume_quotas_class_mock.get.assert_called_with(
+ identity_fakes.project_id)
diff --git a/openstackclient/tests/common/test_utils.py b/openstackclient/tests/common/test_utils.py
index 9c02df31..09545079 100644
--- a/openstackclient/tests/common/test_utils.py
+++ b/openstackclient/tests/common/test_utils.py
@@ -370,6 +370,15 @@ class TestFindResource(test_utils.TestCase):
self.assertEqual(expected, utils.format_list(['a', 'b', 'c']))
self.assertEqual(expected, utils.format_list(['c', 'b', 'a']))
+ def test_format_list_of_dicts(self):
+ expected = "a='b', c='d'\ne='f'"
+ sorted_data = [{'a': 'b', 'c': 'd'}, {'e': 'f'}]
+ unsorted_data = [{'c': 'd', 'a': 'b'}, {'e': 'f'}]
+ self.assertEqual(expected, utils.format_list_of_dicts(sorted_data))
+ self.assertEqual(expected, utils.format_list_of_dicts(unsorted_data))
+ self.assertEqual('', utils.format_list_of_dicts([]))
+ self.assertEqual('', utils.format_list_of_dicts([{}]))
+
def test_format_list_separator(self):
expected = 'a\nb\nc'
actual_pre_sorted = utils.format_list(['a', 'b', 'c'], separator='\n')