Fix bug with association on creation

This commit is contained in:
AlanCoding
2020-03-20 17:49:31 -04:00
parent bd7c048113
commit a72e885274
2 changed files with 26 additions and 2 deletions

View File

@@ -56,6 +56,27 @@ def test_associate_hosts_and_groups(run_module, admin_user, organization):
assert set(group.children.all()) == set([child])
@pytest.mark.django_db
def test_associate_on_create(run_module, admin_user, organization):
inv = Inventory.objects.create(name='test-inv', organization=organization)
child = Group.objects.create(name='test-child', inventory=inv)
host = Host.objects.create(name='test-host', inventory=inv)
result = run_module('tower_group', dict(
name='Test Group',
inventory='test-inv',
hosts=[host.name],
groups=[child.name],
state='present'
), admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert result['changed'] is True
group = Group.objects.get(pk=result['id'])
assert set(group.hosts.all()) == set([host])
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