summaryrefslogtreecommitdiff
path: root/openstackclient/tests/unit
diff options
context:
space:
mode:
authorzhanghongtao <zhanghongtao0826@126.com>2017-07-25 15:48:27 +0800
committerDean Troyer <dtroyer@gmail.com>2017-07-25 09:56:50 -0500
commit470a1f1acfe261357fc3125b2db3bc6ec10c654e (patch)
treeefe4dd9a783784696d11c7add1f02ab9f2d7b1d8 /openstackclient/tests/unit
parentad21588b20bba71da5d0d6bd88aa2530d656a9da (diff)
downloadpython-openstackclient-470a1f1acfe261357fc3125b2db3bc6ec10c654e.tar.gz
Add optional parameter "user_id" and "type" to list credentials
In keystone version 3.5, "type" optional attribute has been added to list credentials. This patch add "user_id" and "type" optional parameter in openstack client. Change-Id: Ia09ee7c39204fdff2dfd7b9b606d888d007caac5
Diffstat (limited to 'openstackclient/tests/unit')
-rw-r--r--openstackclient/tests/unit/identity/v3/test_credential.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/openstackclient/tests/unit/identity/v3/test_credential.py b/openstackclient/tests/unit/identity/v3/test_credential.py
index ce0fb5ae..161f0484 100644
--- a/openstackclient/tests/unit/identity/v3/test_credential.py
+++ b/openstackclient/tests/unit/identity/v3/test_credential.py
@@ -225,12 +225,15 @@ class TestCredentialList(TestCredential):
def setUp(self):
super(TestCredentialList, self).setUp()
+ self.user = identity_fakes.FakeUser.create_one_user()
+ self.users_mock.get.return_value = self.user
+
self.credentials_mock.list.return_value = [self.credential]
# Get the command object to test
self.cmd = credential.ListCredential(self.app, None)
- def test_domain_list_no_options(self):
+ def test_credential_list_no_options(self):
arglist = []
verifylist = []
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@@ -241,6 +244,31 @@ class TestCredentialList(TestCredential):
self.assertEqual(self.columns, columns)
self.assertEqual(self.data, tuple(data))
+ def test_credential_list_with_options(self):
+ arglist = [
+ '--user', self.credential.user_id,
+ '--type', self.credential.type,
+ ]
+ verifylist = [
+ ('user', self.credential.user_id),
+ ('type', self.credential.type),
+ ]
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ columns, data = self.cmd.take_action(parsed_args)
+
+ kwargs = {
+ 'user_id': self.user.id,
+ 'type': self.credential.type,
+ }
+ self.users_mock.get.assert_called_with(self.credential.user_id)
+ self.credentials_mock.list.assert_called_with(
+ **kwargs
+ )
+
+ self.assertEqual(self.columns, columns)
+ self.assertEqual(self.data, tuple(data))
+
class TestCredentialSet(TestCredential):