delete user role on deletion of a user

This commit is contained in:
AlanCoding
2018-04-03 14:31:56 -04:00
parent 8e51f61afa
commit a52b22ffdf
2 changed files with 31 additions and 1 deletions

View File

@@ -1,9 +1,10 @@
import pytest
from django.test import TransactionTestCase
from django.contrib.contenttypes.models import ContentType
from awx.main.access import UserAccess
from awx.main.models import User, Organization, Inventory
from awx.main.models import User, Organization, Inventory, Role
@pytest.mark.django_db
@@ -102,6 +103,27 @@ def test_org_user_removed(user, organization):
assert admin not in member.admin_role
@pytest.mark.django_db
def test_create_user_role(rando):
assert Role.objects.filter(
role_field='admin_role',
content_type=ContentType.objects.get_for_model(User),
object_id=rando.id
).count() == 1
assert rando in rando.admin_role
@pytest.mark.django_db
def test_user_role_deleted(rando):
rando_id = rando.id
rando.delete()
assert not Role.objects.filter(
role_field='admin_role',
content_type=ContentType.objects.get_for_model(User),
object_id=rando_id
)
@pytest.mark.django_db
def test_org_admin_create_sys_auditor(org_admin):
access = UserAccess(org_admin)