move circular group association validation to view

This commit is contained in:
AlanCoding
2017-07-10 09:12:02 -04:00
parent b79600d2e5
commit fed2eddf07
3 changed files with 25 additions and 8 deletions

View File

@@ -0,0 +1,15 @@
import pytest
from awx.api.versioning import reverse
from awx.main.models import Group
@pytest.mark.django_db
def test_cyclical_association_prohibited(post, inventory, admin_user):
parent = Group.objects.create(inventory=inventory, name='parent_group')
child = parent.children.create(inventory=inventory, name='child_group')
# Attempt to make parent a child of the child
url = reverse('api:group_children_list', kwargs={'pk': child.id})
response = post(url, dict(id=parent.id), admin_user, expect=400)
assert 'cyclical' in response.data['error'].lower()