mirror of
https://github.com/ansible/awx.git
synced 2026-05-10 19:07:36 -02:30
Clean-up intiail commit for Host filter / DynamicInventory
This commit is contained in:
@@ -2,7 +2,11 @@ import pytest
|
||||
import mock
|
||||
|
||||
# AWX
|
||||
from awx.main.models import InventorySource, InventoryUpdate
|
||||
from awx.main.models import (
|
||||
Inventory,
|
||||
InventorySource,
|
||||
InventoryUpdate,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@@ -31,3 +35,31 @@ class TestSCMUpdateFeatures:
|
||||
scm_inventory_source.description = "I'm testing this!"
|
||||
scm_inventory_source.save()
|
||||
assert not mck_update.called
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_host_objects_manager(organization):
|
||||
dynamic_inventory = Inventory(organization=organization, name='dynamic', host_filter='inventory_sources__source=ec2')
|
||||
dynamic_inventory.save()
|
||||
|
||||
ec2_inv = Inventory(name='test_ec2', organization=organization)
|
||||
ec2_inv.save()
|
||||
|
||||
ec2_source = ec2_inv.inventory_sources.create(name='test_ec2_source', source='ec2')
|
||||
for i in range(2):
|
||||
ec2_host = ec2_inv.hosts.create(name='test_ec2_{0}'.format(i))
|
||||
ec2_host.inventory_sources.add(ec2_source)
|
||||
ec2_inv.save()
|
||||
|
||||
gce_inv = Inventory(name='test_gce', organization=organization)
|
||||
gce_inv.save()
|
||||
|
||||
gce_source = gce_inv.inventory_sources.create(name='test_gce_source', source='gce')
|
||||
gce_host = gce_inv.hosts.create(name='test_gce_host')
|
||||
gce_host.inventory_sources.add(gce_source)
|
||||
gce_inv.save()
|
||||
|
||||
hosts = dynamic_inventory.hosts.all()
|
||||
assert len(hosts) == 2
|
||||
assert hosts[0].inventory_sources.first() == ec2_source
|
||||
assert hosts[1].inventory_sources.first() == ec2_source
|
||||
|
||||
Reference in New Issue
Block a user