1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-30 05:25:29 +03:00

flake8 fixups

This commit is contained in:
Wayne Witzel III 2016-02-08 10:24:21 -05:00
parent 1418e95155
commit 9ddabeff83
2 changed files with 45 additions and 56 deletions

View File

@ -4,7 +4,6 @@ from awx.main.models.credential import Credential
from awx.main.models.inventory import Inventory
from awx.main.models.organization import (
Organization,
Permission,
Team,
)
from django.contrib.auth.models import User

View File

@ -1,16 +1,6 @@
import pytest
from awx.main.access import OrganizationAccess
from awx.main.models import (
Inventory,
Permission,
PERM_INVENTORY_ADMIN,
PERM_INVENTORY_READ,
PERM_INVENTORY_WRITE,
PERM_INVENTORY_DEPLOY,
PERM_INVENTORY_CHECK,
PERM_INVENTORY_SCAN,
)
from awx.main.models import Permission
@pytest.mark.django_db
def test_inventory_admin_user(inventory, permissions, user):
@ -18,15 +8,15 @@ def test_inventory_admin_user(inventory, permissions, user):
perm = Permission(user=u, inventory=inventory, permission_type='admin')
perm.save()
assert inventory.accessible_by(u, permissions['admin']) == False
assert inventory.accessible_by(u, permissions['admin']) is False
migrations = inventory.migrate_to_rbac()
assert len(migrations['migrated_users']) == 1
assert len(migrations['migrated_teams']) == 0
assert inventory.accessible_by(u, permissions['admin'])
assert not inventory.executor_role.members.filter(id=u.id).exists()
assert not inventory.updater_role.members.filter(id=u.id).exists()
assert inventory.executor_role.members.filter(id=u.id).exists() is False
assert inventory.updater_role.members.filter(id=u.id).exists() is False
@pytest.mark.django_db
def test_inventory_auditor_user(inventory, permissions, user):
@ -34,17 +24,17 @@ def test_inventory_auditor_user(inventory, permissions, user):
perm = Permission(user=u, inventory=inventory, permission_type='read')
perm.save()
assert inventory.accessible_by(u, permissions['admin']) == False
assert inventory.accessible_by(u, permissions['auditor']) == False
assert inventory.accessible_by(u, permissions['admin']) is False
assert inventory.accessible_by(u, permissions['auditor']) is False
migrations = inventory.migrate_to_rbac()
assert len(migrations['migrated_users']) == 1
assert len(migrations['migrated_teams']) == 0
assert inventory.accessible_by(u, permissions['admin']) == False
assert inventory.accessible_by(u, permissions['auditor']) == True
assert not inventory.executor_role.members.filter(id=u.id).exists()
assert not inventory.updater_role.members.filter(id=u.id).exists()
assert inventory.accessible_by(u, permissions['admin']) is False
assert inventory.accessible_by(u, permissions['auditor']) is True
assert inventory.executor_role.members.filter(id=u.id).exists() is False
assert inventory.updater_role.members.filter(id=u.id).exists() is False
@pytest.mark.django_db
def test_inventory_updater_user(inventory, permissions, user):
@ -52,15 +42,15 @@ def test_inventory_updater_user(inventory, permissions, user):
perm = Permission(user=u, inventory=inventory, permission_type='write')
perm.save()
assert inventory.accessible_by(u, permissions['admin']) == False
assert inventory.accessible_by(u, permissions['auditor']) == False
assert inventory.accessible_by(u, permissions['admin']) is False
assert inventory.accessible_by(u, permissions['auditor']) is False
migrations = inventory.migrate_to_rbac()
assert len(migrations['migrated_users']) == 1
assert len(migrations['migrated_teams']) == 0
assert inventory.accessible_by(u, permissions['admin']) == False
assert not inventory.executor_role.members.filter(id=u.id).exists()
assert inventory.accessible_by(u, permissions['admin']) is False
assert inventory.executor_role.members.filter(id=u.id).exists() is False
assert inventory.updater_role.members.filter(id=u.id).exists()
@pytest.mark.django_db
@ -69,17 +59,17 @@ def test_inventory_executor_user(inventory, permissions, user):
perm = Permission(user=u, inventory=inventory, permission_type='read', run_ad_hoc_commands=True)
perm.save()
assert inventory.accessible_by(u, permissions['admin']) == False
assert inventory.accessible_by(u, permissions['auditor']) == False
assert inventory.accessible_by(u, permissions['admin']) is False
assert inventory.accessible_by(u, permissions['auditor']) is False
migrations = inventory.migrate_to_rbac()
assert len(migrations['migrated_users']) == 1
assert len(migrations['migrated_teams']) == 0
assert inventory.accessible_by(u, permissions['admin']) == False
assert inventory.accessible_by(u, permissions['auditor']) == True
assert inventory.accessible_by(u, permissions['admin']) is False
assert inventory.accessible_by(u, permissions['auditor']) is True
assert inventory.executor_role.members.filter(id=u.id).exists()
assert not inventory.updater_role.members.filter(id=u.id).exists()
assert inventory.updater_role.members.filter(id=u.id).exists() is False
@ -90,7 +80,7 @@ def test_inventory_admin_team(inventory, permissions, user, team):
perm.save()
team.users.add(u)
assert inventory.accessible_by(u, permissions['admin']) == False
assert inventory.accessible_by(u, permissions['admin']) is False
team_migrations = team.migrate_to_rbac()
migrations = inventory.migrate_to_rbac()
@ -99,10 +89,10 @@ def test_inventory_admin_team(inventory, permissions, user, team):
assert team.member_role.members.count() == 1
assert len(migrations['migrated_users']) == 0
assert len(migrations['migrated_teams']) == 1
assert not inventory.admin_role.members.filter(id=u.id).exists()
assert not inventory.auditor_role.members.filter(id=u.id).exists()
assert not inventory.executor_role.members.filter(id=u.id).exists()
assert not inventory.updater_role.members.filter(id=u.id).exists()
assert inventory.admin_role.members.filter(id=u.id).exists() is False
assert inventory.auditor_role.members.filter(id=u.id).exists() is False
assert inventory.executor_role.members.filter(id=u.id).exists() is False
assert inventory.updater_role.members.filter(id=u.id).exists() is False
assert inventory.accessible_by(u, permissions['auditor'])
assert inventory.accessible_by(u, permissions['admin'])
@ -114,8 +104,8 @@ def test_inventory_auditor(inventory, permissions, user, team):
perm.save()
team.users.add(u)
assert inventory.accessible_by(u, permissions['admin']) == False
assert inventory.accessible_by(u, permissions['auditor']) == False
assert inventory.accessible_by(u, permissions['admin']) is False
assert inventory.accessible_by(u, permissions['auditor']) is False
team_migrations = team.migrate_to_rbac()
migrations = inventory.migrate_to_rbac()
@ -124,12 +114,12 @@ def test_inventory_auditor(inventory, permissions, user, team):
assert team.member_role.members.count() == 1
assert len(migrations['migrated_users']) == 0
assert len(migrations['migrated_teams']) == 1
assert not inventory.admin_role.members.filter(id=u.id).exists()
assert not inventory.auditor_role.members.filter(id=u.id).exists()
assert not inventory.executor_role.members.filter(id=u.id).exists()
assert not inventory.updater_role.members.filter(id=u.id).exists()
assert inventory.admin_role.members.filter(id=u.id).exists() is False
assert inventory.auditor_role.members.filter(id=u.id).exists() is False
assert inventory.executor_role.members.filter(id=u.id).exists() is False
assert inventory.updater_role.members.filter(id=u.id).exists() is False
assert inventory.accessible_by(u, permissions['auditor'])
assert not inventory.accessible_by(u, permissions['admin'])
assert inventory.accessible_by(u, permissions['admin']) is False
@pytest.mark.django_db
def test_inventory_updater(inventory, permissions, user, team):
@ -138,8 +128,8 @@ def test_inventory_updater(inventory, permissions, user, team):
perm.save()
team.users.add(u)
assert inventory.accessible_by(u, permissions['admin']) == False
assert inventory.accessible_by(u, permissions['auditor']) == False
assert inventory.accessible_by(u, permissions['admin']) is False
assert inventory.accessible_by(u, permissions['auditor']) is False
team_migrations = team.migrate_to_rbac()
migrations = inventory.migrate_to_rbac()
@ -148,12 +138,12 @@ def test_inventory_updater(inventory, permissions, user, team):
assert team.member_role.members.count() == 1
assert len(migrations['migrated_users']) == 0
assert len(migrations['migrated_teams']) == 1
assert not inventory.admin_role.members.filter(id=u.id).exists()
assert not inventory.auditor_role.members.filter(id=u.id).exists()
assert not inventory.executor_role.members.filter(id=u.id).exists()
assert not inventory.updater_role.members.filter(id=u.id).exists()
assert inventory.admin_role.members.filter(id=u.id).exists() is False
assert inventory.auditor_role.members.filter(id=u.id).exists() is False
assert inventory.executor_role.members.filter(id=u.id).exists() is False
assert inventory.updater_role.members.filter(id=u.id).exists() is False
assert team.member_role.is_ancestor_of(inventory.updater_role)
assert not team.member_role.is_ancestor_of(inventory.executor_role)
assert team.member_role.is_ancestor_of(inventory.executor_role) is False
@pytest.mark.django_db
@ -163,8 +153,8 @@ def test_inventory_executor(inventory, permissions, user, team):
perm.save()
team.users.add(u)
assert inventory.accessible_by(u, permissions['admin']) == False
assert inventory.accessible_by(u, permissions['auditor']) == False
assert inventory.accessible_by(u, permissions['admin']) is False
assert inventory.accessible_by(u, permissions['auditor']) is False
team_migrations = team.migrate_to_rbac()
migrations = inventory.migrate_to_rbac()
@ -173,10 +163,10 @@ def test_inventory_executor(inventory, permissions, user, team):
assert team.member_role.members.count() == 1
assert len(migrations['migrated_users']) == 0
assert len(migrations['migrated_teams']) == 1
assert not inventory.admin_role.members.filter(id=u.id).exists()
assert not inventory.auditor_role.members.filter(id=u.id).exists()
assert not inventory.executor_role.members.filter(id=u.id).exists()
assert not inventory.updater_role.members.filter(id=u.id).exists()
assert not team.member_role.is_ancestor_of(inventory.updater_role)
assert inventory.admin_role.members.filter(id=u.id).exists() is False
assert inventory.auditor_role.members.filter(id=u.id).exists() is False
assert inventory.executor_role.members.filter(id=u.id).exists() is False
assert inventory.updater_role.members.filter(id=u.id).exists() is False
assert team.member_role.is_ancestor_of(inventory.updater_role) is False
assert team.member_role.is_ancestor_of(inventory.executor_role)