Small fix of adding role to the user
Made a small fix of adding role to the user: setting clear
variables. In the corner case when the 'admin' user is
not present, or it is has other username, or the domain is
different, the tests tried to find the only "admin" user in
the default domain only.
Also, there is a couple of minor fixes according to the PEP8
codestyle.
Related-PROD: PROD-36943
Change-Id: Ic891c4b54479adf85f88081d742cb7af45fc4639
diff --git a/fixtures/base.py b/fixtures/base.py
index d1434dd..ed00d80 100644
--- a/fixtures/base.py
+++ b/fixtures/base.py
@@ -115,8 +115,10 @@
# create alt project with regular admin user
tmp_os_actions = os_client.OSCliActions(openstack_clients)
alt_project = tmp_os_actions.create_project()
- tmp_os_actions.add_roles_to_user_in_project(alt_project.id)
-
+ tmp_os_actions.add_roles_to_user_in_project(
+ alt_project.id, username=os.environ['OS_USERNAME'],
+ domain=os.environ['OS_PROJECT_DOMAIN_NAME']
+ )
# create a client using alt project with admin user in it
return os_client.OfficialClientManager(
username=os.environ['OS_USERNAME'],
diff --git a/tests/test_glance.py b/tests/test_glance.py
index 7313fdd..85d070d 100644
--- a/tests/test_glance.py
+++ b/tests/test_glance.py
@@ -19,7 +19,7 @@
"""
try:
to(value)
- except:
+ except BaseException:
return False
return True
diff --git a/utils/__init__.py b/utils/__init__.py
index 190dbd7..e4de308 100644
--- a/utils/__init__.py
+++ b/utils/__init__.py
@@ -10,11 +10,11 @@
def compile_pairs(nodes):
result = {}
- if len(nodes) %2 != 0:
+ if len(nodes) % 2 != 0:
nodes.pop(1)
pairs = list(zip(*[iter(nodes)] * 2))
for pair in pairs:
- result[pair[0]+'<>'+pair[1]] = pair
+ result[pair[0] + '<>' + pair[1]] = pair
return result