diff options
author | Elijah DeLee <kdelee@redhat.com> | 2023-02-03 16:08:24 +0100 |
---|---|---|
committer | Elijah DeLee <kdelee@redhat.com> | 2023-03-08 18:58:12 +0100 |
commit | 9e037f1a0224a13183e6cd4553cf78bd7b9e341c (patch) | |
tree | 7154ea05846006d59d54ede035c692db407c0623 /awx_collection/test | |
parent | add the extra vars support and configuration for max job and hosts (diff) | |
download | awx-9e037f1a0224a13183e6cd4553cf78bd7b9e341c.tar.xz awx-9e037f1a0224a13183e6cd4553cf78bd7b9e341c.zip |
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
Diffstat (limited to 'awx_collection/test')
-rw-r--r-- | awx_collection/test/awx/test_bulk.py | 42 | ||||
-rw-r--r-- | awx_collection/test/awx/test_completeness.py | 12 |
2 files changed, 54 insertions, 0 deletions
diff --git a/awx_collection/test/awx/test_bulk.py b/awx_collection/test/awx/test_bulk.py new file mode 100644 index 0000000000..fbccf3d1d8 --- /dev/null +++ b/awx_collection/test/awx/test_bulk.py @@ -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
\ No newline at end of file diff --git a/awx_collection/test/awx/test_completeness.py b/awx_collection/test/awx/test_completeness.py index 451c1a61d3..ef3d70727a 100644 --- a/awx_collection/test/awx/test_completeness.py +++ b/awx_collection/test/awx/test_completeness.py @@ -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) |