mirror of
https://github.com/ansible/awx.git
synced 2026-02-28 08:18:43 -03:30
Updated fact tests to use the divergent group fixture
A group fixture was created in different ways, one on devel and one on rbac, this patch just normalizes to the one usage
This commit is contained in:
@@ -151,18 +151,23 @@ def organizations(instance):
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def group(inventory):
|
def group(inventory):
|
||||||
def g(name):
|
def g(name):
|
||||||
return Group.objects.create(inventory=inventory, name=name)
|
try:
|
||||||
|
return Group.objects.get(name=name, inventory=inventory)
|
||||||
|
except:
|
||||||
|
return Group.objects.create(inventory=inventory, name=name)
|
||||||
return g
|
return g
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def hosts(group):
|
def hosts(group):
|
||||||
|
group1 = group('group-1')
|
||||||
|
|
||||||
def rf(host_count=1):
|
def rf(host_count=1):
|
||||||
hosts = []
|
hosts = []
|
||||||
for i in xrange(0, host_count):
|
for i in xrange(0, host_count):
|
||||||
name = '%s-host-%s' % (group.name, i)
|
name = '%s-host-%s' % (group1.name, i)
|
||||||
(host, created) = group.inventory.hosts.get_or_create(name=name)
|
(host, created) = group1.inventory.hosts.get_or_create(name=name)
|
||||||
if created:
|
if created:
|
||||||
group.hosts.add(host)
|
group1.hosts.add(host)
|
||||||
hosts.append(host)
|
hosts.append(host)
|
||||||
return hosts
|
return hosts
|
||||||
return rf
|
return rf
|
||||||
@@ -307,6 +312,8 @@ def options():
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def fact_scans(group, fact_ansible_json, fact_packages_json, fact_services_json):
|
def fact_scans(group, fact_ansible_json, fact_packages_json, fact_services_json):
|
||||||
|
group1 = group('group-1')
|
||||||
|
|
||||||
def rf(fact_scans=1, timestamp_epoch=timezone.now()):
|
def rf(fact_scans=1, timestamp_epoch=timezone.now()):
|
||||||
facts_json = {}
|
facts_json = {}
|
||||||
facts = []
|
facts = []
|
||||||
@@ -318,7 +325,7 @@ def fact_scans(group, fact_ansible_json, fact_packages_json, fact_services_json)
|
|||||||
facts_json['services'] = fact_services_json
|
facts_json['services'] = fact_services_json
|
||||||
|
|
||||||
for i in xrange(0, fact_scans):
|
for i in xrange(0, fact_scans):
|
||||||
for host in group.hosts.all():
|
for host in group1.hosts.all():
|
||||||
for module_name in module_names:
|
for module_name in module_names:
|
||||||
facts.append(Fact.objects.create(host=host, timestamp=timestamp_current, module=module_name, facts=facts_json[module_name]))
|
facts.append(Fact.objects.create(host=host, timestamp=timestamp_current, module=module_name, facts=facts_json[module_name]))
|
||||||
timestamp_current += timedelta(days=1)
|
timestamp_current += timedelta(days=1)
|
||||||
|
|||||||
Reference in New Issue
Block a user