fixup return values for bulk launch and host create in awxkit

Enabled the params bulk job

make black

make black again

Fixed inventory and organization input params for bulk modules

add collection integration tests

Fix cli return errors

fix test completeness
This commit is contained in:
Elijah DeLee
2023-02-03 10:08:24 -05:00
parent 266ebe5501
commit 9e037f1a02
11 changed files with 365 additions and 42 deletions

View File

@@ -0,0 +1,42 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
import pytest
from awx.main.models import WorkflowJob
@pytest.mark.django_db
def test_bulk_job_launch(run_module, admin_user, job_template):
jobs = [dict(unified_job_template=job_template.id)]
result = run_module(
'bulk_job_launch',
{
'name': "foo-bulk-job",
'jobs': jobs,
'extra_vars': {'animal': 'owl'},
'limit': 'foo',
'wait': False,
},
admin_user,
)
bulk_job = WorkflowJob.objects.get(name="foo-bulk-job")
assert bulk_job.extra_vars == '{"animal": "owl"}'
assert bulk_job.limit == "foo"
@pytest.mark.django_db
def test_bulk_host_create(run_module, admin_user, inventory):
hosts = [dict(name="127.0.0.1"), dict(name="foo.dns.org")]
result = run_module(
'bulk_host_create',
{
'inventory': inventory.id,
'hosts': hosts,
},
admin_user,
)
resp_hosts = inventory.hosts.all().values_list('name', flat=True)
for h in hosts:
assert h['name'] in resp_hosts

View File

@@ -44,6 +44,12 @@ no_endpoint_for_module = [
'subscriptions', # Subscription deals with config/subscriptions
]
# Add modules with endpoints that are not at /api/v2
extra_endpoints = {
'bulk_job_launch': '/api/v2/bulk/job_launch/',
'bulk_host_create': '/api/v2/bulk/host_create/',
}
# Global module parameters we can ignore
ignore_parameters = ['state', 'new_name', 'update_secrets', 'copy_from']
@@ -73,6 +79,8 @@ no_api_parameter_ok = {
'user': ['new_username', 'organization'],
# workflow_approval parameters that do not apply when approving an approval node.
'workflow_approval': ['action', 'interval', 'timeout', 'workflow_job_id'],
# bulk
'bulk_job_launch': ['interval', 'wait'],
}
# When this tool was created we were not feature complete. Adding something in here indicates a module
@@ -228,6 +236,10 @@ def test_completeness(collection_import, request, admin_user, job_template, exec
user=admin_user,
expect=None,
)
for key, val in extra_endpoints.items():
endpoint_response.data[key] = val
for endpoint in endpoint_response.data.keys():
# Module names are singular and endpoints are plural so we need to convert to singular
singular_endpoint = '{0}'.format(endpoint)