mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
Fix bug with association on creation
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user