mirror of
https://github.com/ansible/awx.git
synced 2026-02-02 10:08:10 -03:30
Initial commit of ad hoc module
This commit is contained in:
55
awx_collection/test/awx/test_ad_hoc_wait.py
Normal file
55
awx_collection/test/awx/test_ad_hoc_wait.py
Normal file
@@ -0,0 +1,55 @@
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import pytest
|
||||
from django.utils.timezone import now
|
||||
|
||||
from awx.main.models.ad_hoc_commands import AdHocCommand
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_ad_hoc_command_wait_successful(run_module, admin_user):
|
||||
command = AdHocCommand.objects.create(status='successful', started=now(), finished=now())
|
||||
result = run_module('tower_ad_hoc_command_wait', dict(
|
||||
command_id=command.id
|
||||
), admin_user)
|
||||
result.pop('invocation', None)
|
||||
assert result.pop('finished', '')[:10] == str(command.finished)[:10]
|
||||
assert result.pop('started', '')[:10] == str(command.started)[:10]
|
||||
assert result == {
|
||||
"status": "successful",
|
||||
"changed": False,
|
||||
"elapsed": str(command.elapsed),
|
||||
"id": command.id
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_ad_hoc_command_wait_failed(run_module, admin_user):
|
||||
command = AdHocCommand.objects.create(status='failed', started=now(), finished=now())
|
||||
result = run_module('tower_ad_hoc_command_wait', dict(
|
||||
command_id=command.id
|
||||
), admin_user)
|
||||
result.pop('invocation', None)
|
||||
assert result.pop('finished', '')[:10] == str(command.finished)[:10]
|
||||
assert result.pop('started', '')[:10] == str(command.started)[:10]
|
||||
assert result == {
|
||||
"status": "failed",
|
||||
"failed": True,
|
||||
"changed": False,
|
||||
"elapsed": str(command.elapsed),
|
||||
"id": command.id,
|
||||
"msg": "The ad hoc command - 1, failed"
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_ad_hoc_command_wait_not_found(run_module, admin_user):
|
||||
result = run_module('tower_ad_hoc_command_wait', dict(
|
||||
command_id=42
|
||||
), admin_user)
|
||||
result.pop('invocation', None)
|
||||
assert result == {
|
||||
"failed": True,
|
||||
"msg": "Unable to wait on ad hoc command 42; that ID does not exist in Tower."
|
||||
}
|
||||
@@ -25,7 +25,7 @@ no_module_for_endpoint = []
|
||||
no_endpoint_for_module = [
|
||||
'tower_import', 'tower_meta', 'tower_export', 'tower_inventory_source_update', 'tower_job_launch', 'tower_job_wait',
|
||||
'tower_job_list', 'tower_license', 'tower_ping', 'tower_receive', 'tower_send', 'tower_workflow_launch',
|
||||
'tower_job_cancel', 'tower_workflow_template',
|
||||
'tower_job_cancel', 'tower_workflow_template', 'tower_ad_hoc_command_wait', 'tower_ad_hoc_command_cancel',
|
||||
]
|
||||
|
||||
# Global module parameters we can ignore
|
||||
@@ -48,6 +48,8 @@ no_api_parameter_ok = {
|
||||
'tower_workflow_job_template_node': ['organization'],
|
||||
# Survey is how we handle associations
|
||||
'tower_workflow_job_template': ['survey'],
|
||||
# ad hoc commands support interval and timeout since its more like tower_job_launc
|
||||
'tower_ad_hoc_command': ['interval', 'timeout', 'wait'],
|
||||
}
|
||||
|
||||
# When this tool was created we were not feature complete. Adding something in here indicates a module
|
||||
|
||||
Reference in New Issue
Block a user