diff options
author | Juan Antonio Osorio Robles <jaosorior@redhat.com> | 2018-11-22 15:32:18 +0200 |
---|---|---|
committer | Juan Antonio Osorio Robles <jaosorior@redhat.com> | 2018-11-22 15:32:18 +0200 |
commit | a10275772627caad4c4fa66effa26ecd2a6ecd7b (patch) | |
tree | aa98f9693b96369b2a2848adef56f1739d871d00 | |
parent | f79650325f459e12bbac8f6967dcfabece1de7a4 (diff) | |
download | oslo-policy-a10275772627caad4c4fa66effa26ecd2a6ecd7b.tar.gz |
Fix usage of token fixture in shell tests1.41.1
The way we were using the token fixture in the shell tests was modifying
the structure. If the test would get run by the same process, it would
then use the modified structure and the test would fail.
This uses deepcopy instead, so this way, we never modify that fixture.
Change-Id: Ib88feee7d7fe72c66b4e8af510f9f28411ac47df
-rw-r--r-- | oslo_policy/tests/test_shell.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/oslo_policy/tests/test_shell.py b/oslo_policy/tests/test_shell.py index 97c64c8..0d7fe64 100644 --- a/oslo_policy/tests/test_shell.py +++ b/oslo_policy/tests/test_shell.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +import copy import mock from oslo_serialization import jsonutils @@ -44,7 +45,8 @@ class CheckerTestCase(base.PolicyBaseTestCase): is_admin = False stdout = self._capture_stdout() - access_data = token_fixture.SCOPED_TOKEN_FIXTURE["token"] + access_data = copy.deepcopy( + token_fixture.SCOPED_TOKEN_FIXTURE["token"]) target = { "project_id": access_data['project']['id'] } @@ -66,7 +68,8 @@ class CheckerTestCase(base.PolicyBaseTestCase): def test_pass_rule_parameters_with_custom_target(self, call_mock): apply_rule = None is_admin = False - access_data = token_fixture.SCOPED_TOKEN_FIXTURE["token"] + access_data = copy.deepcopy( + token_fixture.SCOPED_TOKEN_FIXTURE["token"]) access_data['roles'] = [ role['name'] for role in access_data['roles']] access_data['project_id'] = access_data['project']['id'] |