mirror of
https://github.com/ansible/awx.git
synced 2026-01-14 11:20:39 -03:30
adjusting test and renaming helper
This commit is contained in:
parent
a6e97626ba
commit
ec505f3f60
@ -27,8 +27,8 @@ from .fixtures import (
|
||||
from .exc import NotUnique
|
||||
|
||||
|
||||
def build_role_objects(objects):
|
||||
'''build_role_objects assembles a dictionary of all possible objects by name.
|
||||
def generate_role_objects(objects):
|
||||
'''generate_role_objects assembles a dictionary of all possible objects by name.
|
||||
It will raise an exception if any of the objects share a name due to the fact that
|
||||
it is to be used with apply_roles, which expects unique object names.
|
||||
|
||||
@ -201,7 +201,7 @@ def create_job_template(name, **kwargs):
|
||||
inventory=inv, credential=cred,
|
||||
job_type=job_type, persisted=persisted)
|
||||
|
||||
role_objects = build_role_objects([org, proj, inv, cred])
|
||||
role_objects = generate_role_objects([org, proj, inv, cred])
|
||||
apply_roles(kwargs.get('roles'), role_objects, persisted)
|
||||
|
||||
return Objects(job_template=jt,
|
||||
@ -245,7 +245,7 @@ def create_organization(name, **kwargs):
|
||||
else:
|
||||
notification_templates[nt] = mk_notification_template(nt, organization=org, persisted=persisted)
|
||||
|
||||
role_objects = build_role_objects([org, superusers, users, teams, projects, labels, notification_templates])
|
||||
role_objects = generate_role_objects([org, superusers, users, teams, projects, labels, notification_templates])
|
||||
apply_roles(kwargs.get('roles'), role_objects, persisted)
|
||||
return Objects(organization=org,
|
||||
superusers=_Mapped(superusers),
|
||||
@ -271,7 +271,7 @@ def create_notification_template(name, **kwargs):
|
||||
superusers = generate_users(organization, teams, True, persisted, superusers=kwargs.get('superusers'))
|
||||
users = generate_users(organization, teams, False, persisted, users=kwargs.get('users'))
|
||||
|
||||
role_objects = build_role_objects([organization, notification_template])
|
||||
role_objects = generate_role_objects([organization, notification_template])
|
||||
apply_roles(kwargs.get('roles'), role_objects, persisted)
|
||||
return Objects(notification_template=notification_template,
|
||||
organization=organization,
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import mock # noqa
|
||||
import pytest
|
||||
|
||||
from django.db import transaction
|
||||
from django.core.urlresolvers import reverse
|
||||
from awx.main.models import Project
|
||||
|
||||
@ -71,12 +70,6 @@ def test_team_project_list(get, team_project_list):
|
||||
assert get(reverse('api:team_projects_list', args=(team2.pk,)), alice).data['count'] == 1
|
||||
team2.read_role.members.remove(alice)
|
||||
|
||||
# Test user endpoints first, very similar tests to test_user_project_list
|
||||
# but permissions are being derived from team membership instead.
|
||||
with transaction.atomic():
|
||||
res = get(reverse('api:user_projects_list', args=(bob.pk,)), alice)
|
||||
assert res.status_code == 403
|
||||
|
||||
# admins can see all projects
|
||||
assert get(reverse('api:user_projects_list', args=(admin.pk,)), admin).data['count'] == 3
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user