From 911c3bcdd6be8bc5ce39737a36d445baa110dc22 Mon Sep 17 00:00:00 2001 From: chenhb-zte Date: Wed, 20 Jul 2016 08:51:15 +0800 Subject: [PATCH] Add the unit-test of add_and_remove_user_role Add a unit-test case test_add_and_remove_user_role for add_and_remove_user_role. Change-Id: I170bbab7581bbeb431e0fc1451288e1deff74538 --- .../scenarios/keystone/test_basic.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) mode change 100644 => 100755 tests/unit/plugins/openstack/scenarios/keystone/test_basic.py diff --git a/tests/unit/plugins/openstack/scenarios/keystone/test_basic.py b/tests/unit/plugins/openstack/scenarios/keystone/test_basic.py old mode 100644 new mode 100755 index 143dc8a1..b7ecf258 --- a/tests/unit/plugins/openstack/scenarios/keystone/test_basic.py +++ b/tests/unit/plugins/openstack/scenarios/keystone/test_basic.py @@ -270,3 +270,22 @@ class KeystoneBasicTestCase(test.ScenarioTestCase): "fake_user_id", "fake_tenant_id") scenario._delete_ec2credential.assert_called_once_with( "fake_user_id", fake_creds.access) + + def test_add_and_remove_user_role(self): + context = self._get_context() + tenant_id = context["tenant"]["id"] + user_id = context["user"]["id"] + + scenario = basic.KeystoneBasic(context) + fake_role = mock.MagicMock() + scenario._role_create = mock.MagicMock(return_value=fake_role) + scenario._role_add = mock.MagicMock() + scenario._role_remove = mock.MagicMock() + + scenario.add_and_remove_user_role() + + scenario._role_create.assert_called_once_with() + scenario._role_add.assert_called_once_with( + user_id, fake_role, tenant_id) + scenario._role_remove.assert_called_once_with( + user_id, fake_role, tenant_id)