mirror of
https://github.com/ansible/awx.git
synced 2026-03-21 10:57:36 -02:30
tower_group relationships
rollback some module_utils changes add runtime error for 404 type things
This commit is contained in:
@@ -3,7 +3,7 @@ __metaclass__ = type
|
||||
|
||||
import pytest
|
||||
|
||||
from awx.main.models import Organization, Inventory, Group
|
||||
from awx.main.models import Organization, Inventory, Group, Host
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -32,6 +32,30 @@ def test_create_group(run_module, admin_user):
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_associate_hosts_and_groups(run_module, admin_user, organization):
|
||||
inv = Inventory.objects.create(name='test-inv', organization=organization)
|
||||
group = Group.objects.create(name='Test Group', inventory=inv)
|
||||
|
||||
inv_hosts = [Host.objects.create(inventory=inv, name='foo{0}'.format(i)) for i in range(3)]
|
||||
group.hosts.add(inv_hosts[0], inv_hosts[1])
|
||||
|
||||
child = Group.objects.create(inventory=inv, name='child_group')
|
||||
|
||||
result = run_module('tower_group', dict(
|
||||
name='Test Group',
|
||||
inventory='test-inv',
|
||||
hosts=[inv_hosts[1].name, inv_hosts[2].name],
|
||||
groups=[child.name],
|
||||
state='present'
|
||||
), admin_user)
|
||||
assert not result.get('failed', False), result.get('msg', result)
|
||||
assert result['changed'] is True
|
||||
|
||||
assert set(group.hosts.all()) == set([inv_hosts[1], inv_hosts[2]])
|
||||
assert set(group.children.all()) == set([child])
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_tower_group_idempotent(run_module, admin_user):
|
||||
# https://github.com/ansible/ansible/issues/46803
|
||||
|
||||
Reference in New Issue
Block a user