[Identity] Check return value is None in identity v3 unit tests

take_action() in commands inheriting from Command returns nothing.
So we should assert the return is None in the unit tests of these
commands.

Change-Id: I02af06b3d476aac2d93a23ef2111cdc7fa0892ec
Partial-Bug: #1550636
This commit is contained in:
Tang Chen 2016-03-05 16:29:18 +08:00
parent 752705ae30
commit 762c4c9bdf
9 changed files with 64 additions and 30 deletions

View File

@ -96,9 +96,11 @@ class TestCredentialSet(TestCredential):
'--data', self.json_data,
identity_fakes.credential_id,
]
parsed_args = self.check_parser(self.cmd, arglist, [])
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
self.assertIsNone(result)
def test_credential_set_valid_with_project(self):
arglist = [
@ -108,6 +110,8 @@ class TestCredentialSet(TestCredential):
'--project', identity_fakes.project_name,
identity_fakes.credential_id,
]
parsed_args = self.check_parser(self.cmd, arglist, [])
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
self.assertIsNone(result)

View File

@ -258,10 +258,13 @@ class TestIdentityProviderDelete(TestIdentityProvider):
('identity_provider', identity_fakes.idp_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
self.identity_providers_mock.delete.assert_called_with(
identity_fakes.idp_id,
)
self.assertIsNone(result)
class TestIdentityProviderList(TestIdentityProvider):

View File

@ -92,11 +92,13 @@ class TestMappingDelete(TestMapping):
verifylist = [
('mapping', identity_fakes.mapping_id)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
self.mapping_mock.delete.assert_called_with(
identity_fakes.mapping_id)
self.assertIsNone(result)
class TestMappingList(TestMapping):
@ -234,7 +236,6 @@ class TestMappingSet(TestMapping):
('mapping', identity_fakes.mapping_id),
('rules', identity_fakes.mapping_rules_file_path)
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.assertRaises(

View File

@ -92,9 +92,12 @@ class TestProtocolDelete(TestProtocol):
('identity_provider', identity_fakes.idp_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
self.protocols_mock.delete.assert_called_with(
identity_fakes.idp_id, identity_fakes.protocol_id)
self.assertIsNone(result)
class TestProtocolList(TestProtocol):

View File

@ -306,11 +306,12 @@ class TestRoleDelete(TestRole):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
self.roles_mock.delete.assert_called_with(
identity_fakes.role_id,
)
self.assertIsNone(result)
class TestRoleList(TestRole):
@ -640,7 +641,7 @@ class TestRoleRemove(TestRole):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
# Set expected values
kwargs = {
@ -653,6 +654,7 @@ class TestRoleRemove(TestRole):
identity_fakes.role_id,
**kwargs
)
self.assertIsNone(result)
def test_role_remove_user_project(self):
arglist = [
@ -672,7 +674,7 @@ class TestRoleRemove(TestRole):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
# Set expected values
kwargs = {
@ -685,6 +687,7 @@ class TestRoleRemove(TestRole):
identity_fakes.role_id,
**kwargs
)
self.assertIsNone(result)
def test_role_remove_group_domain(self):
arglist = [
@ -705,7 +708,7 @@ class TestRoleRemove(TestRole):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
# Set expected values
kwargs = {
@ -718,6 +721,7 @@ class TestRoleRemove(TestRole):
identity_fakes.role_id,
**kwargs
)
self.assertIsNone(result)
def test_role_remove_group_project(self):
arglist = [
@ -737,7 +741,7 @@ class TestRoleRemove(TestRole):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
# Set expected values
kwargs = {
@ -750,6 +754,7 @@ class TestRoleRemove(TestRole):
identity_fakes.role_id,
**kwargs
)
self.assertIsNone(result)
class TestRoleSet(TestRole):
@ -778,7 +783,7 @@ class TestRoleSet(TestRole):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
# Set expected values
kwargs = {
@ -789,6 +794,7 @@ class TestRoleSet(TestRole):
identity_fakes.role_id,
**kwargs
)
self.assertIsNone(result)
class TestRoleShow(TestRole):

View File

@ -188,10 +188,13 @@ class TestServiceProviderDelete(TestServiceProvider):
('service_provider', service_fakes.sp_id),
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
self.service_providers_mock.delete.assert_called_with(
service_fakes.sp_id,
)
self.assertIsNone(result)
class TestServiceProviderList(TestServiceProvider):

View File

@ -123,6 +123,7 @@ class TestTokenRevoke(TestToken):
verifylist = [('token', self.TOKEN)]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
self.tokens_mock.revoke_token.assert_called_with(self.TOKEN)
self.assertIsNone(result)

View File

@ -141,11 +141,12 @@ class TestTrustDelete(TestTrust):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
self.trusts_mock.delete.assert_called_with(
identity_fakes.trust_id,
)
self.assertIsNone(result)
class TestTrustList(TestTrust):

View File

@ -499,11 +499,12 @@ class TestUserDelete(TestUser):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
self.users_mock.delete.assert_called_with(
identity_fakes.user_id,
)
self.assertIsNone(result)
class TestUserList(TestUser):
@ -774,7 +775,7 @@ class TestUserSet(TestUser):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
# Set expected values
kwargs = {
@ -787,6 +788,7 @@ class TestUserSet(TestUser):
identity_fakes.user_id,
**kwargs
)
self.assertIsNone(result)
def test_user_set_password(self):
arglist = [
@ -805,7 +807,7 @@ class TestUserSet(TestUser):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
# Set expected values
kwargs = {
@ -818,6 +820,7 @@ class TestUserSet(TestUser):
identity_fakes.user_id,
**kwargs
)
self.assertIsNone(result)
def test_user_set_password_prompt(self):
arglist = [
@ -839,7 +842,7 @@ class TestUserSet(TestUser):
mocker = mock.Mock()
mocker.return_value = 'abc123'
with mock.patch("openstackclient.common.utils.get_password", mocker):
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
# Set expected values
kwargs = {
@ -852,6 +855,7 @@ class TestUserSet(TestUser):
identity_fakes.user_id,
**kwargs
)
self.assertIsNone(result)
def test_user_set_email(self):
arglist = [
@ -869,7 +873,7 @@ class TestUserSet(TestUser):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
# Set expected values
kwargs = {
@ -882,6 +886,7 @@ class TestUserSet(TestUser):
identity_fakes.user_id,
**kwargs
)
self.assertIsNone(result)
def test_user_set_project(self):
arglist = [
@ -899,7 +904,7 @@ class TestUserSet(TestUser):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
# Set expected values
kwargs = {
@ -912,6 +917,7 @@ class TestUserSet(TestUser):
identity_fakes.user_id,
**kwargs
)
self.assertIsNone(result)
def test_user_set_project_domain(self):
arglist = [
@ -931,7 +937,7 @@ class TestUserSet(TestUser):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
# Set expected values
kwargs = {
@ -944,6 +950,7 @@ class TestUserSet(TestUser):
identity_fakes.user_id,
**kwargs
)
self.assertIsNone(result)
def test_user_set_enable(self):
arglist = [
@ -961,7 +968,7 @@ class TestUserSet(TestUser):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
# Set expected values
kwargs = {
@ -973,6 +980,7 @@ class TestUserSet(TestUser):
identity_fakes.user_id,
**kwargs
)
self.assertIsNone(result)
def test_user_set_disable(self):
arglist = [
@ -990,7 +998,7 @@ class TestUserSet(TestUser):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
# Set expected values
kwargs = {
@ -1002,6 +1010,7 @@ class TestUserSet(TestUser):
identity_fakes.user_id,
**kwargs
)
self.assertIsNone(result)
class TestUserSetPassword(TestUser):
@ -1030,11 +1039,12 @@ class TestUserSetPassword(TestUser):
# Mock getting user current password.
with self._mock_get_password(current_pass):
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
self.users_mock.update_password.assert_called_with(
current_pass, new_pass
)
self.assertIsNone(result)
def test_user_create_password_prompt(self):
current_pass = 'old_pass'
@ -1043,11 +1053,12 @@ class TestUserSetPassword(TestUser):
# Mock getting user current and new password.
with self._mock_get_password(current_pass, new_pass):
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
self.users_mock.update_password.assert_called_with(
current_pass, new_pass
)
self.assertIsNone(result)
def test_user_password_change_no_prompt(self):
current_pass = 'old_pass'
@ -1062,11 +1073,12 @@ class TestUserSetPassword(TestUser):
]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
self.cmd.take_action(parsed_args)
result = self.cmd.take_action(parsed_args)
self.users_mock.update_password.assert_called_with(
current_pass, new_pass
)
self.assertIsNone(result)
class TestUserShow(TestUser):