From 9ddabeff83bbb061f2ab0341bc071c00f6e5051d Mon Sep 17 00:00:00 2001 From: Wayne Witzel III Date: Mon, 8 Feb 2016 10:24:21 -0500 Subject: [PATCH] flake8 fixups --- awx/main/tests/functional/conftest.py | 1 - .../tests/functional/test_rbac_inventory.py | 100 ++++++++---------- 2 files changed, 45 insertions(+), 56 deletions(-) diff --git a/awx/main/tests/functional/conftest.py b/awx/main/tests/functional/conftest.py index 7d0a770b27..31e6eebf6c 100644 --- a/awx/main/tests/functional/conftest.py +++ b/awx/main/tests/functional/conftest.py @@ -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 diff --git a/awx/main/tests/functional/test_rbac_inventory.py b/awx/main/tests/functional/test_rbac_inventory.py index 0d9c71d156..478de37d18 100644 --- a/awx/main/tests/functional/test_rbac_inventory.py +++ b/awx/main/tests/functional/test_rbac_inventory.py @@ -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)