more rename, mostly in test

This commit is contained in:
Seth Foster
2021-04-29 11:58:41 -04:00
parent a695274cb6
commit 7a63785255
105 changed files with 616 additions and 625 deletions

View File

@@ -11,7 +11,7 @@ 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 = run_module('ad_hoc_command_wait', dict(command_id=command.id), admin_user)
result.pop('invocation', None)
result['elapsed'] = float(result['elapsed'])
assert result.pop('finished', '')[:10] == str(command.finished)[:10]
@@ -22,7 +22,7 @@ def test_ad_hoc_command_wait_successful(run_module, admin_user):
@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 = run_module('ad_hoc_command_wait', dict(command_id=command.id), admin_user)
result.pop('invocation', None)
result['elapsed'] = float(result['elapsed'])
assert result.pop('finished', '')[:10] == str(command.finished)[:10]
@@ -39,6 +39,6 @@ def test_ad_hoc_command_wait_failed(run_module, admin_user):
@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 = run_module('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."}

View File

@@ -21,7 +21,7 @@ def test_create_application(run_module, admin_user):
'organization': 'foo',
}
result = run_module('tower_application', module_args, admin_user)
result = run_module('application', module_args, admin_user)
assert result.get('changed'), result
application = OAuth2Application.objects.get(name='foo_app')

View File

@@ -16,7 +16,7 @@ import re
# Normally a read-only endpoint should not have a module (i.e. /api/v2/me) but sometimes we reuse a name
# For example, we have a tower_role module but /api/v2/roles is a read only endpoint.
# This list indicates which read-only endpoints have associated modules with them.
read_only_endpoints_with_modules = ['tower_settings', 'tower_role', 'tower_project_update']
read_only_endpoints_with_modules = ['settings', 'role', 'project_update']
# If a module should not be created for an endpoint and the endpoint is not read-only add it here
# THINK HARD ABOUT DOING THIS
@@ -24,23 +24,23 @@ no_module_for_endpoint = []
# Some modules work on the related fields of an endpoint. These modules will not have an auto-associated 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_workflow_node_wait',
'tower_job_cancel',
'tower_workflow_template',
'tower_ad_hoc_command_wait',
'tower_ad_hoc_command_cancel',
'import',
'meta',
'export',
'inventory_source_update',
'job_launch',
'job_wait',
'job_list',
'license',
'ping',
'receive',
'send',
'workflow_launch',
'workflow_node_wait',
'job_cancel',
'workflow_template',
'ad_hoc_command_wait',
'ad_hoc_command_cancel',
]
# Global module parameters we can ignore
@@ -50,32 +50,32 @@ ignore_parameters = ['state', 'new_name', 'update_secrets', 'copy_from']
# Add the module name as the key with the value being the list of params to ignore
no_api_parameter_ok = {
# The wait is for whether or not to wait for a project update on change
'tower_project': ['wait', 'interval', 'update_project'],
'project': ['wait', 'interval', 'update_project'],
# Existing_token and id are for working with an existing tokens
'tower_token': ['existing_token', 'existing_token_id'],
'token': ['existing_token', 'existing_token_id'],
# /survey spec is now how we handle associations
# We take an organization here to help with the lookups only
'tower_job_template': ['survey_spec', 'organization'],
'tower_inventory_source': ['organization'],
'job_template': ['survey_spec', 'organization'],
'inventory_source': ['organization'],
# Organization is how we are looking up job templates, Approval node is for workflow_approval_templates
'tower_workflow_job_template_node': ['organization', 'approval_node'],
'workflow_job_template_node': ['organization', 'approval_node'],
# Survey is how we handle associations
'tower_workflow_job_template': ['survey_spec', 'destroy_current_schema'],
'workflow_job_template': ['survey_spec', 'destroy_current_schema'],
# ad hoc commands support interval and timeout since its more like tower_job_launch
'tower_ad_hoc_command': ['interval', 'timeout', 'wait'],
'ad_hoc_command': ['interval', 'timeout', 'wait'],
# tower_group parameters to perserve hosts and children.
'tower_group': ['preserve_existing_children', 'preserve_existing_hosts'],
'group': ['preserve_existing_children', 'preserve_existing_hosts'],
# tower_workflow_approval parameters that do not apply when approving an approval node.
'tower_workflow_approval': ['action', 'interval', 'timeout', 'workflow_job_id'],
'workflow_approval': ['action', 'interval', 'timeout', 'workflow_job_id'],
}
# When this tool was created we were not feature complete. Adding something in here indicates a module
# that needs to be developed. If the module is found on the file system it will auto-detect that the
# work is being done and will bypass this check. At some point this module should be removed from this list.
needs_development = ['tower_inventory_script']
needs_development = ['inventory_script']
needs_param_development = {
'tower_host': ['instance_id'],
'tower_workflow_approval': ['description', 'execution_environment'],
'host': ['instance_id'],
'workflow_approval': ['description', 'execution_environment'],
}
# -----------------------------------------------------------------------------------------------------------
@@ -192,7 +192,7 @@ def test_completeness(collection_import, request, admin_user, job_template, exec
singular_endpoint = singular_endpoint[:-3]
if singular_endpoint != 'settings' and singular_endpoint.endswith('s'):
singular_endpoint = singular_endpoint[:-1]
module_name = 'tower_{0}'.format(singular_endpoint)
module_name = '{0}'.format(singular_endpoint)
endpoint_url = endpoint_response.data.get(endpoint)

View File

@@ -29,7 +29,7 @@ def test_create_machine_credential(run_module, admin_user, organization, silence
ct = CredentialType.defaults['ssh']()
ct.save()
# Example from docs
result = run_module('tower_credential', dict(name='Test Machine Credential', organization=organization.name, kind='ssh', state='present'), admin_user)
result = run_module('credential', dict(name='Test Machine Credential', organization=organization.name, kind='ssh', state='present'), admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert result.get('changed'), result
@@ -48,7 +48,7 @@ def test_create_vault_credential(run_module, admin_user, organization, silence_d
ct.save()
result = run_module(
'tower_credential',
'credential',
dict(name='Test Vault Credential', organization=organization.name, kind='vault', vault_id='bar', vault_password='foobar', state='present'),
admin_user,
)
@@ -67,7 +67,7 @@ def test_create_vault_credential(run_module, admin_user, organization, silence_d
@pytest.mark.django_db
def test_ct_precedence_over_kind(run_module, admin_user, organization, cred_type, silence_deprecation):
result = run_module(
'tower_credential', dict(name='A credential', organization=organization.name, kind='ssh', credential_type=cred_type.name, state='present'), admin_user
'credential', dict(name='A credential', organization=organization.name, kind='ssh', credential_type=cred_type.name, state='present'), admin_user
)
assert not result.get('failed', False), result.get('msg', result)
@@ -82,7 +82,7 @@ def test_input_overrides_old_fields(run_module, admin_user, organization, silenc
ct = CredentialType.defaults['vault']()
ct.save()
result = run_module(
'tower_credential',
'credential',
dict(
name='A Vault credential',
organization=organization.name,
@@ -103,7 +103,7 @@ def test_input_overrides_old_fields(run_module, admin_user, organization, silenc
@pytest.mark.django_db
def test_missing_credential_type(run_module, admin_user, organization):
Organization.objects.create(name='test-org')
result = run_module('tower_credential', dict(name='A credential', organization=organization.name, credential_type='foobar', state='present'), admin_user)
result = run_module('credential', dict(name='A credential', organization=organization.name, credential_type='foobar', state='present'), admin_user)
assert result.get('failed', False), result
assert 'credential_type' in result['msg']
assert 'foobar' in result['msg']
@@ -113,7 +113,7 @@ def test_missing_credential_type(run_module, admin_user, organization):
@pytest.mark.django_db
def test_make_use_of_custom_credential_type(run_module, organization, admin_user, cred_type):
result = run_module(
'tower_credential',
'credential',
dict(name='Galaxy Token for Steve', organization=organization.name, credential_type=cred_type.name, inputs={'token': '7rEZK38DJl58A7RxA6EC7lLvUHbBQ1'}),
admin_user,
)
@@ -137,7 +137,7 @@ def test_secret_field_write_twice(run_module, organization, admin_user, cred_typ
val2 = '7rEZ238DJl5837rxA6xxxlLvUHbBQ1'
for val in (val1, val2):
result = run_module(
'tower_credential',
'credential',
dict(
name='Galaxy Token for Steve',
organization=organization.name,

View File

@@ -29,7 +29,7 @@ def test_aim_credential_source(run_module, admin_user, organization, source_cred
tgt_cred = Credential.objects.create(name='Test Machine Credential', organization=organization, credential_type=ct, inputs={'username': 'bob'})
result = run_module(
'tower_credential_input_source',
'credential_input_source',
dict(
source_credential=source_cred_aim.name,
target_credential=tgt_cred.name,
@@ -73,7 +73,7 @@ def test_conjur_credential_source(run_module, admin_user, organization, source_c
tgt_cred = Credential.objects.create(name='Test Machine Credential', organization=organization, credential_type=ct, inputs={'username': 'bob'})
result = run_module(
'tower_credential_input_source',
'credential_input_source',
dict(
source_credential=source_cred_conjur.name,
target_credential=tgt_cred.name,
@@ -123,7 +123,7 @@ def test_hashi_secret_credential_source(run_module, admin_user, organization, so
tgt_cred = Credential.objects.create(name='Test Machine Credential', organization=organization, credential_type=ct, inputs={'username': 'bob'})
result = run_module(
'tower_credential_input_source',
'credential_input_source',
dict(
source_credential=source_cred_hashi_secret.name,
target_credential=tgt_cred.name,
@@ -170,7 +170,7 @@ def test_hashi_ssh_credential_source(run_module, admin_user, organization, sourc
tgt_cred = Credential.objects.create(name='Test Machine Credential', organization=organization, credential_type=ct, inputs={'username': 'bob'})
result = run_module(
'tower_credential_input_source',
'credential_input_source',
dict(
source_credential=source_cred_hashi_ssh.name,
target_credential=tgt_cred.name,
@@ -224,7 +224,7 @@ def test_azure_kv_credential_source(run_module, admin_user, organization, source
tgt_cred = Credential.objects.create(name='Test Machine Credential', organization=organization, credential_type=ct, inputs={'username': 'bob'})
result = run_module(
'tower_credential_input_source',
'credential_input_source',
dict(
source_credential=source_cred_azure_kv.name,
target_credential=tgt_cred.name,
@@ -265,7 +265,7 @@ def test_aim_credential_source(run_module, admin_user, organization, source_cred
tgt_cred = Credential.objects.create(name='Test Machine Credential', organization=organization, credential_type=ct, inputs={'username': 'bob'})
result = run_module(
'tower_credential_input_source',
'credential_input_source',
dict(
source_credential=source_cred_aim.name,
target_credential=tgt_cred.name,
@@ -280,7 +280,7 @@ def test_aim_credential_source(run_module, admin_user, organization, source_cred
assert result.get('changed'), result
unchangedResult = run_module(
'tower_credential_input_source',
'credential_input_source',
dict(
source_credential=source_cred_aim.name,
target_credential=tgt_cred.name,
@@ -295,7 +295,7 @@ def test_aim_credential_source(run_module, admin_user, organization, source_cred
assert not unchangedResult.get('changed'), result
changedResult = run_module(
'tower_credential_input_source',
'credential_input_source',
dict(source_credential=source_cred_aim_alt.name, target_credential=tgt_cred.name, input_field_name='password', state='present'),
admin_user,
)
@@ -336,7 +336,7 @@ def test_centrify_vault_credential_source(run_module, admin_user, organization,
tgt_cred = Credential.objects.create(name='Test Machine Credential', organization=organization, credential_type=ct, inputs={'username': 'bob'})
result = run_module(
'tower_credential_input_source',
'credential_input_source',
dict(
source_credential=source_cred_centrify_secret.name,
target_credential=tgt_cred.name,

View File

@@ -11,7 +11,7 @@ from awx.main.models import CredentialType
def test_create_custom_credential_type(run_module, admin_user, silence_deprecation):
# Example from docs
result = run_module(
'tower_credential_type',
'credential_type',
dict(
name='Nexus',
description='Credentials type for Nexus',
@@ -37,7 +37,7 @@ def test_create_custom_credential_type(run_module, admin_user, silence_deprecati
@pytest.mark.django_db
def test_changed_false_with_api_changes(run_module, admin_user):
result = run_module(
'tower_credential_type',
'credential_type',
dict(
name='foo',
kind='cloud',
@@ -50,7 +50,7 @@ def test_changed_false_with_api_changes(run_module, admin_user):
assert result.get('changed'), result
result = run_module(
'tower_credential_type',
'credential_type',
dict(
name='foo',
inputs={"fields": [{"id": "env_value", "label": "foo", "default": "foo"}]},

View File

@@ -13,7 +13,7 @@ def test_create_group(run_module, admin_user):
inv = Inventory.objects.create(name='test-inv', organization=org)
variables = {"ansible_network_os": "iosxr"}
result = run_module('tower_group', dict(name='Test Group', inventory='test-inv', variables=variables, state='present'), admin_user)
result = run_module('group', dict(name='Test Group', inventory='test-inv', variables=variables, state='present'), admin_user)
assert result.get('changed'), result
group = Group.objects.get(name='Test Group')
@@ -39,7 +39,7 @@ def test_associate_hosts_and_children(run_module, admin_user, organization):
child = Group.objects.create(inventory=inv, name='child_group')
result = run_module(
'tower_group',
'group',
dict(name='Test Group', inventory='test-inv', hosts=[inv_hosts[1].name, inv_hosts[2].name], children=[child.name], state='present'),
admin_user,
)
@@ -56,7 +56,7 @@ def test_associate_on_create(run_module, admin_user, organization):
child = Group.objects.create(name='test-child', inventory=inv)
host = Host.objects.create(name='test-host', inventory=inv)
result = run_module('tower_group', dict(name='Test Group', inventory='test-inv', hosts=[host.name], groups=[child.name], state='present'), admin_user)
result = run_module('group', dict(name='Test Group', inventory='test-inv', hosts=[host.name], groups=[child.name], state='present'), admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert result['changed'] is True
@@ -70,7 +70,7 @@ def test_children_alias_of_groups(run_module, admin_user, organization):
inv = Inventory.objects.create(name='test-inv', organization=organization)
group = Group.objects.create(name='Test Group', inventory=inv)
child = Group.objects.create(inventory=inv, name='child_group')
result = run_module('tower_group', dict(name='Test Group', inventory='test-inv', groups=[child.name], state='present'), admin_user)
result = run_module('group', dict(name='Test Group', inventory='test-inv', groups=[child.name], state='present'), admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert result['changed'] is True
@@ -87,7 +87,7 @@ def test_tower_group_idempotent(run_module, admin_user):
inventory=inv,
)
result = run_module('tower_group', dict(name='Test Group', inventory='test-inv', state='present'), admin_user)
result = run_module('group', dict(name='Test Group', inventory='test-inv', state='present'), admin_user)
result.pop('invocation')
assert result == {

View File

@@ -11,7 +11,7 @@ from awx.main.tests.functional.conftest import kube_credential, credentialtype_k
@pytest.mark.django_db
def test_instance_group_create(run_module, admin_user):
result = run_module(
'tower_instance_group', {'name': 'foo-group', 'policy_instance_percentage': 34, 'policy_instance_minimum': 12, 'state': 'present'}, admin_user
'instance_group', {'name': 'foo-group', 'policy_instance_percentage': 34, 'policy_instance_minimum': 12, 'state': 'present'}, admin_user
)
assert not result.get('failed', False), result
assert result['changed']
@@ -24,7 +24,7 @@ def test_instance_group_create(run_module, admin_user):
new_instance = Instance.objects.create(hostname='foo.example.com')
# Set the new instance group only to the one instnace
result = run_module('tower_instance_group', {'name': 'foo-group', 'instances': [new_instance.hostname], 'state': 'present'}, admin_user)
result = run_module('instance_group', {'name': 'foo-group', 'instances': [new_instance.hostname], 'state': 'present'}, admin_user)
assert not result.get('failed', False), result
assert result['changed']
@@ -41,9 +41,7 @@ def test_instance_group_create(run_module, admin_user):
def test_container_group_create(run_module, admin_user, kube_credential):
pod_spec = "{ 'Nothing': True }"
result = run_module(
'tower_instance_group', {'name': 'foo-c-group', 'credential': kube_credential.id, 'is_container_group': True, 'state': 'present'}, admin_user
)
result = run_module('instance_group', {'name': 'foo-c-group', 'credential': kube_credential.id, 'is_container_group': True, 'state': 'present'}, admin_user)
assert not result.get('failed', False), result['msg']
assert result['changed']
@@ -51,7 +49,7 @@ def test_container_group_create(run_module, admin_user, kube_credential):
assert ig.pod_spec_override == ''
result = run_module(
'tower_instance_group',
'instance_group',
{'name': 'foo-c-group', 'credential': kube_credential.id, 'is_container_group': True, 'pod_spec_override': pod_spec, 'state': 'present'},
admin_user,
)

View File

@@ -13,7 +13,7 @@ def test_inventory_create(run_module, admin_user, organization, insights_credent
# Create an insights credential
result = run_module(
'tower_inventory',
'inventory',
{
'name': 'foo-inventory',
'organization': organization.name,
@@ -39,7 +39,7 @@ def test_inventory_create(run_module, admin_user, organization, insights_credent
@pytest.mark.django_db
def test_invalid_smart_inventory_create(run_module, admin_user, organization):
result = run_module(
'tower_inventory',
'inventory',
{'name': 'foo-inventory', 'organization': organization.name, 'kind': 'smart', 'host_filter': 'ansible', 'state': 'present'},
admin_user,
)
@@ -51,7 +51,7 @@ def test_invalid_smart_inventory_create(run_module, admin_user, organization):
@pytest.mark.django_db
def test_valid_smart_inventory_create(run_module, admin_user, organization):
result = run_module(
'tower_inventory',
'inventory',
{'name': 'foo-inventory', 'organization': organization.name, 'kind': 'smart', 'host_filter': 'name=my_host', 'state': 'present'},
admin_user,
)

View File

@@ -28,7 +28,7 @@ def project(base_inventory):
def test_inventory_source_create(run_module, admin_user, base_inventory, project):
source_path = '/var/lib/awx/example_source_path/'
result = run_module(
'tower_inventory_source',
'inventory_source',
dict(name='foo', inventory=base_inventory.name, state='present', source='scm', source_path=source_path, source_project=project.name),
admin_user,
)
@@ -49,7 +49,7 @@ def test_create_inventory_source_implied_org(run_module, admin_user):
inv = Inventory.objects.create(name='test-inv', organization=org)
# Credential is not required for ec2 source, because of IAM roles
result = run_module('tower_inventory_source', dict(name='Test Inventory Source', inventory='test-inv', source='ec2', state='present'), admin_user)
result = run_module('inventory_source', dict(name='Test Inventory Source', inventory='test-inv', source='ec2', state='present'), admin_user)
assert result.pop('changed', None), result
inv_src = InventorySource.objects.get(name='Test Inventory Source')
@@ -72,7 +72,7 @@ def test_create_inventory_source_multiple_orgs(run_module, admin_user):
inv2 = Inventory.objects.create(name='test-inv', organization=org2)
result = run_module(
'tower_inventory_source',
'inventory_source',
dict(name='Test Inventory Source', inventory=inv2.name, organization='test-org-number-two', source='ec2', state='present'),
admin_user,
)
@@ -90,14 +90,14 @@ def test_create_inventory_source_multiple_orgs(run_module, admin_user):
@pytest.mark.django_db
def test_falsy_value(run_module, admin_user, base_inventory):
result = run_module('tower_inventory_source', dict(name='falsy-test', inventory=base_inventory.name, source='ec2', update_on_launch=True), admin_user)
result = run_module('inventory_source', dict(name='falsy-test', inventory=base_inventory.name, source='ec2', update_on_launch=True), admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert result.get('changed', None), result
inv_src = InventorySource.objects.get(name='falsy-test')
assert inv_src.update_on_launch is True
result = run_module('tower_inventory_source', dict(name='falsy-test', inventory=base_inventory.name, source='ec2', update_on_launch=False), admin_user)
result = run_module('inventory_source', dict(name='falsy-test', inventory=base_inventory.name, source='ec2', update_on_launch=False), admin_user)
inv_src.refresh_from_db()
assert inv_src.update_on_launch is False
@@ -127,7 +127,7 @@ def test_falsy_value(run_module, admin_user, base_inventory):
@pytest.mark.django_db
def test_missing_required_credential(run_module, admin_user, base_inventory):
result = run_module('tower_inventory_source', dict(name='Test Azure Source', inventory=base_inventory.name, source='azure_rm', state='present'), admin_user)
result = run_module('inventory_source', dict(name='Test Azure Source', inventory=base_inventory.name, source='azure_rm', state='present'), admin_user)
assert result.pop('failed', None) is True, result
assert 'Credential is required for a cloud source' in result.get('msg', '')
@@ -136,7 +136,7 @@ def test_missing_required_credential(run_module, admin_user, base_inventory):
@pytest.mark.django_db
def test_source_project_not_for_cloud(run_module, admin_user, base_inventory, project):
result = run_module(
'tower_inventory_source',
'inventory_source',
dict(name='Test ec2 Inventory Source', inventory=base_inventory.name, source='ec2', state='present', source_project=project.name),
admin_user,
)
@@ -148,7 +148,7 @@ def test_source_project_not_for_cloud(run_module, admin_user, base_inventory, pr
@pytest.mark.django_db
def test_source_path_not_for_cloud(run_module, admin_user, base_inventory):
result = run_module(
'tower_inventory_source',
'inventory_source',
dict(name='Test ec2 Inventory Source', inventory=base_inventory.name, source='ec2', state='present', source_path='where/am/I'),
admin_user,
)
@@ -160,7 +160,7 @@ def test_source_path_not_for_cloud(run_module, admin_user, base_inventory):
@pytest.mark.django_db
def test_scm_source_needs_project(run_module, admin_user, base_inventory):
result = run_module(
'tower_inventory_source',
'inventory_source',
dict(
name='SCM inventory without project', inventory=base_inventory.name, state='present', source='scm', source_path='/var/lib/awx/example_source_path/'
),

View File

@@ -11,7 +11,7 @@ from awx.main.models import Job
@pytest.mark.django_db
def test_job_wait_successful(run_module, admin_user):
job = Job.objects.create(status='successful', started=now(), finished=now())
result = run_module('tower_job_wait', dict(job_id=job.id), admin_user)
result = run_module('job_wait', dict(job_id=job.id), admin_user)
result.pop('invocation', None)
result['elapsed'] = float(result['elapsed'])
assert result.pop('finished', '')[:10] == str(job.finished)[:10]
@@ -22,7 +22,7 @@ def test_job_wait_successful(run_module, admin_user):
@pytest.mark.django_db
def test_job_wait_failed(run_module, admin_user):
job = Job.objects.create(status='failed', started=now(), finished=now())
result = run_module('tower_job_wait', dict(job_id=job.id), admin_user)
result = run_module('job_wait', dict(job_id=job.id), admin_user)
result.pop('invocation', None)
result['elapsed'] = float(result['elapsed'])
assert result.pop('finished', '')[:10] == str(job.finished)[:10]
@@ -32,6 +32,6 @@ def test_job_wait_failed(run_module, admin_user):
@pytest.mark.django_db
def test_job_wait_not_found(run_module, admin_user):
result = run_module('tower_job_wait', dict(job_id=42), admin_user)
result = run_module('job_wait', dict(job_id=42), admin_user)
result.pop('invocation', None)
assert result == {"failed": True, "msg": "Unable to wait on job 42; that ID does not exist in Tower."}

View File

@@ -20,7 +20,7 @@ def test_create_job_template(run_module, admin_user, project, inventory):
'state': 'present',
}
result = run_module('tower_job_template', module_args, admin_user)
result = run_module('job_template', module_args, admin_user)
jt = JobTemplate.objects.get(name='foo')
assert jt.extra_vars == '{"foo": "bar"}'
@@ -48,7 +48,7 @@ def test_resets_job_template_values(run_module, admin_user, project, inventory):
'ask_limit_on_launch': True,
}
result = run_module('tower_job_template', module_args, admin_user)
result = run_module('job_template', module_args, admin_user)
jt = JobTemplate.objects.get(name='foo')
assert jt.forks == 20
@@ -70,7 +70,7 @@ def test_resets_job_template_values(run_module, admin_user, project, inventory):
'ask_limit_on_launch': False,
}
result = run_module('tower_job_template', module_args, admin_user)
result = run_module('job_template', module_args, admin_user)
assert result['changed']
jt = JobTemplate.objects.get(name='foo')
@@ -92,7 +92,7 @@ def test_job_launch_with_prompting(run_module, admin_user, project, organization
ask_credential_on_launch=True,
)
result = run_module(
'tower_job_launch',
'job_launch',
dict(
job_template='foo',
inventory=inventory.name,
@@ -112,7 +112,7 @@ def test_job_launch_with_prompting(run_module, admin_user, project, organization
@pytest.mark.django_db
def test_job_template_with_new_credentials(run_module, admin_user, project, inventory, machine_credential, vault_credential):
result = run_module(
'tower_job_template',
'job_template',
dict(
name='foo', playbook='helloworld.yml', project=project.name, inventory=inventory.name, credentials=[machine_credential.name, vault_credential.name]
),
@@ -126,7 +126,7 @@ def test_job_template_with_new_credentials(run_module, admin_user, project, inve
prior_ct = ActivityStream.objects.count()
result = run_module(
'tower_job_template',
'job_template',
dict(
name='foo', playbook='helloworld.yml', project=project.name, inventory=inventory.name, credentials=[machine_credential.name, vault_credential.name]
),
@@ -144,7 +144,7 @@ def test_job_template_with_new_credentials(run_module, admin_user, project, inve
@pytest.mark.django_db
def test_job_template_with_survey_spec(run_module, admin_user, project, inventory, survey_spec):
result = run_module(
'tower_job_template',
'job_template',
dict(name='foo', playbook='helloworld.yml', project=project.name, inventory=inventory.name, survey_spec=survey_spec, survey_enabled=True),
admin_user,
)
@@ -156,7 +156,7 @@ def test_job_template_with_survey_spec(run_module, admin_user, project, inventor
prior_ct = ActivityStream.objects.count()
result = run_module(
'tower_job_template',
'job_template',
dict(name='foo', playbook='helloworld.yml', project=project.name, inventory=inventory.name, survey_spec=survey_spec, survey_enabled=True),
admin_user,
)
@@ -172,7 +172,7 @@ def test_job_template_with_survey_spec(run_module, admin_user, project, inventor
@pytest.mark.django_db
def test_job_template_with_wrong_survey_spec(run_module, admin_user, project, inventory, survey_spec):
result = run_module(
'tower_job_template',
'job_template',
dict(name='foo', playbook='helloworld.yml', project=project.name, inventory=inventory.name, survey_spec=survey_spec, survey_enabled=True),
admin_user,
)
@@ -187,7 +187,7 @@ def test_job_template_with_wrong_survey_spec(run_module, admin_user, project, in
del survey_spec['description']
result = run_module(
'tower_job_template',
'job_template',
dict(name='foo', playbook='helloworld.yml', project=project.name, inventory=inventory.name, survey_spec=survey_spec, survey_enabled=True),
admin_user,
)
@@ -204,7 +204,7 @@ def test_job_template_with_survey_encrypted_default(run_module, admin_user, proj
}
for i in range(2):
result = run_module(
'tower_job_template',
'job_template',
dict(name='foo', playbook='helloworld.yml', project=project.name, inventory=inventory.name, survey_spec=spec, survey_enabled=True),
admin_user,
)
@@ -236,9 +236,7 @@ def test_associate_only_on_success(run_module, admin_user, organization, project
jt.notification_templates_error.add(nt1)
# test preservation of error NTs when success NTs are added
result = run_module(
'tower_job_template', dict(name='foo', playbook='helloworld.yml', project=project.name, notification_templates_success=['nt2']), admin_user
)
result = run_module('job_template', dict(name='foo', playbook='helloworld.yml', project=project.name, notification_templates_success=['nt2']), admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert result.get('changed', True), result
@@ -246,7 +244,7 @@ def test_associate_only_on_success(run_module, admin_user, organization, project
assert list(jt.notification_templates_error.values_list('id', flat=True)) == [nt1.id]
# test removal to empty list
result = run_module('tower_job_template', dict(name='foo', playbook='helloworld.yml', project=project.name, notification_templates_success=[]), admin_user)
result = run_module('job_template', dict(name='foo', playbook='helloworld.yml', project=project.name, notification_templates_success=[]), admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert result.get('changed', True), result

View File

@@ -9,7 +9,7 @@ from awx.main.models import Label
@pytest.mark.django_db
def test_create_label(run_module, admin_user, organization):
result = run_module('tower_label', dict(name='test-label', organization=organization.name), admin_user)
result = run_module('label', dict(name='test-label', organization=organization.name), admin_user)
assert not result.get('failed'), result.get('msg', result)
assert result.get('changed', False)
@@ -18,7 +18,7 @@ def test_create_label(run_module, admin_user, organization):
@pytest.mark.django_db
def test_create_label_using_org_id(run_module, admin_user, organization):
result = run_module('tower_label', dict(name='test-label', organization=organization.id), admin_user)
result = run_module('label', dict(name='test-label', organization=organization.id), admin_user)
assert not result.get('failed'), result.get('msg', result)
assert result.get('changed', False)
@@ -29,7 +29,7 @@ def test_create_label_using_org_id(run_module, admin_user, organization):
def test_modify_label(run_module, admin_user, organization):
label = Label.objects.create(name='test-label', organization=organization)
result = run_module('tower_label', dict(name='test-label', new_name='renamed-label', organization=organization.name), admin_user)
result = run_module('label', dict(name='test-label', new_name='renamed-label', organization=organization.name), admin_user)
assert not result.get('failed'), result.get('msg', result)
assert result.get('changed', False)

View File

@@ -49,12 +49,12 @@ def mock_awx_ping_response(self, method, url, **kwargs):
def test_version_warning(collection_import, silence_warning):
TowerAPIModule = collection_import('plugins.module_utils.tower_api').ControllerAPIModule
ControllerAPIModule = collection_import('plugins.module_utils.controller_api').ControllerAPIModule
cli_data = {'ANSIBLE_MODULE_ARGS': {}}
testargs = ['module_file2.py', json.dumps(cli_data)]
with mock.patch.object(sys, 'argv', testargs):
with mock.patch('ansible.module_utils.urls.Request.open', new=mock_awx_ping_response):
my_module = TowerAPIModule(argument_spec=dict())
my_module = ControllerAPIModule(argument_spec=dict())
my_module._COLLECTION_VERSION = "2.0.0"
my_module._COLLECTION_TYPE = "awx"
my_module.get_endpoint('ping')
@@ -64,13 +64,13 @@ def test_version_warning(collection_import, silence_warning):
def test_version_warning_strictness_awx(collection_import, silence_warning):
TowerAPIModule = collection_import('plugins.module_utils.tower_api').ControllerAPIModule
ControllerAPIModule = collection_import('plugins.module_utils.controller_api').ControllerAPIModule
cli_data = {'ANSIBLE_MODULE_ARGS': {}}
testargs = ['module_file2.py', json.dumps(cli_data)]
# Compare 1.0.0 to 1.2.3 (major matches)
with mock.patch.object(sys, 'argv', testargs):
with mock.patch('ansible.module_utils.urls.Request.open', new=mock_awx_ping_response):
my_module = TowerAPIModule(argument_spec=dict())
my_module = ControllerAPIModule(argument_spec=dict())
my_module._COLLECTION_VERSION = "1.0.0"
my_module._COLLECTION_TYPE = "awx"
my_module.get_endpoint('ping')
@@ -79,7 +79,7 @@ def test_version_warning_strictness_awx(collection_import, silence_warning):
# Compare 1.2.0 to 1.2.3 (major matches minor does not count)
with mock.patch.object(sys, 'argv', testargs):
with mock.patch('ansible.module_utils.urls.Request.open', new=mock_awx_ping_response):
my_module = TowerAPIModule(argument_spec=dict())
my_module = ControllerAPIModule(argument_spec=dict())
my_module._COLLECTION_VERSION = "1.2.0"
my_module._COLLECTION_TYPE = "awx"
my_module.get_endpoint('ping')
@@ -87,13 +87,13 @@ def test_version_warning_strictness_awx(collection_import, silence_warning):
def test_version_warning_strictness_tower(collection_import, silence_warning):
TowerAPIModule = collection_import('plugins.module_utils.tower_api').ControllerAPIModule
ControllerAPIModule = collection_import('plugins.module_utils.controller_api').ControllerAPIModule
cli_data = {'ANSIBLE_MODULE_ARGS': {}}
testargs = ['module_file2.py', json.dumps(cli_data)]
# Compare 1.2.0 to 1.2.3 (major/minor matches)
with mock.patch.object(sys, 'argv', testargs):
with mock.patch('ansible.module_utils.urls.Request.open', new=mock_tower_ping_response):
my_module = TowerAPIModule(argument_spec=dict())
my_module = ControllerAPIModule(argument_spec=dict())
my_module._COLLECTION_VERSION = "1.2.0"
my_module._COLLECTION_TYPE = "tower"
my_module.get_endpoint('ping')
@@ -102,7 +102,7 @@ def test_version_warning_strictness_tower(collection_import, silence_warning):
# Compare 1.0.0 to 1.2.3 (major/minor fail to match)
with mock.patch.object(sys, 'argv', testargs):
with mock.patch('ansible.module_utils.urls.Request.open', new=mock_tower_ping_response):
my_module = TowerAPIModule(argument_spec=dict())
my_module = ControllerAPIModule(argument_spec=dict())
my_module._COLLECTION_VERSION = "1.0.0"
my_module._COLLECTION_TYPE = "tower"
my_module.get_endpoint('ping')
@@ -112,12 +112,12 @@ def test_version_warning_strictness_tower(collection_import, silence_warning):
def test_type_warning(collection_import, silence_warning):
TowerAPIModule = collection_import('plugins.module_utils.tower_api').ControllerAPIModule
ControllerAPIModule = collection_import('plugins.module_utils.controller_api').ControllerAPIModule
cli_data = {'ANSIBLE_MODULE_ARGS': {}}
testargs = ['module_file2.py', json.dumps(cli_data)]
with mock.patch.object(sys, 'argv', testargs):
with mock.patch('ansible.module_utils.urls.Request.open', new=mock_awx_ping_response):
my_module = TowerAPIModule(argument_spec={})
my_module = ControllerAPIModule(argument_spec={})
my_module._COLLECTION_VERSION = ping_version
my_module._COLLECTION_TYPE = "tower"
my_module.get_endpoint('ping')
@@ -128,15 +128,15 @@ def test_type_warning(collection_import, silence_warning):
def test_duplicate_config(collection_import, silence_warning):
# imports done here because of PATH issues unique to this test suite
TowerAPIModule = collection_import('plugins.module_utils.tower_api').ControllerAPIModule
ControllerAPIModule = collection_import('plugins.module_utils.controller_api').ControllerAPIModule
data = {'name': 'zigzoom', 'zig': 'zoom', 'tower_username': 'bob', 'tower_config_file': 'my_config'}
with mock.patch.object(TowerAPIModule, 'load_config') as mock_load:
with mock.patch.object(ControllerAPIModule, 'load_config') as mock_load:
argument_spec = dict(
name=dict(required=True),
zig=dict(type='str'),
)
TowerAPIModule(argument_spec=argument_spec, direct_params=data)
ControllerAPIModule(argument_spec=argument_spec, direct_params=data)
assert mock_load.mock_calls[-1] == mock.call('my_config')
silence_warning.assert_called_once_with(
@@ -152,11 +152,11 @@ def test_no_templated_values(collection_import):
Those replacements should happen at build time, so they should not be
checked into source.
"""
TowerAPIModule = collection_import('plugins.module_utils.tower_api').ControllerAPIModule
assert TowerAPIModule._COLLECTION_VERSION == "0.0.1-devel", (
ControllerAPIModule = collection_import('plugins.module_utils.controller_api').ControllerAPIModule
assert ControllerAPIModule._COLLECTION_VERSION == "0.0.1-devel", (
'The collection version is templated when the collection is built ' 'and the code should retain the placeholder of "0.0.1-devel".'
)
InventoryModule = collection_import('plugins.inventory.tower').InventoryModule
InventoryModule = collection_import('plugins.inventory.controller').InventoryModule
assert InventoryModule.NAME == 'awx.awx.tower', (
'The inventory plugin FQCN is templated when the collection is built ' 'and the code should retain the default of awx.awx.'
)
@@ -172,7 +172,7 @@ def test_conflicting_name_and_id(run_module, admin_user):
org_by_id = Organization.objects.create(name='foo')
slug = str(org_by_id.id)
org_by_name = Organization.objects.create(name=slug)
result = run_module('tower_team', {'name': 'foo_team', 'description': 'fooin around', 'organization': slug}, admin_user)
result = run_module('team', {'name': 'foo_team', 'description': 'fooin around', 'organization': slug}, admin_user)
assert not result.get('failed', False), result.get('msg', result)
team = Team.objects.filter(name='foo_team').first()
assert str(team.organization_id) == slug, 'Lookup by id should be preferenced over name in cases of conflict.'
@@ -195,9 +195,7 @@ def test_multiple_lookup(run_module, admin_user):
scm_type='git',
scm_url="https://github.com/ansible/ansible-tower-samples",
)
result = run_module(
'tower_job_template', {'name': 'Demo Job Template', 'project': proj1.name, 'inventory': inv.id, 'playbook': 'hello_world.yml'}, admin_user
)
result = run_module('job_template', {'name': 'Demo Job Template', 'project': proj1.name, 'inventory': inv.id, 'playbook': 'hello_world.yml'}, admin_user)
assert result.get('failed', False)
assert 'projects' in result['msg']
assert 'foo' in result['msg']

View File

@@ -35,7 +35,7 @@ def test_create_modify_notification_template(run_module, admin_user, organizatio
'timeout': 4,
}
result = run_module(
'tower_notification_template',
'notification_template',
dict(
name='foo-notification-template',
organization=organization.name,
@@ -54,7 +54,7 @@ def test_create_modify_notification_template(run_module, admin_user, organizatio
# Test no-op, this is impossible if the notification_configuration is given
# because we cannot determine if password fields changed
result = run_module(
'tower_notification_template',
'notification_template',
dict(
name='foo-notification-template',
organization=organization.name,
@@ -68,7 +68,7 @@ def test_create_modify_notification_template(run_module, admin_user, organizatio
# Test a change in the configuration
nt_config['timeout'] = 12
result = run_module(
'tower_notification_template',
'notification_template',
dict(
name='foo-notification-template',
organization=organization.name,
@@ -87,7 +87,7 @@ def test_create_modify_notification_template(run_module, admin_user, organizatio
@pytest.mark.django_db
def test_invalid_notification_configuration(run_module, admin_user, organization):
result = run_module(
'tower_notification_template',
'notification_template',
dict(
name='foo-notification-template',
organization=organization.name,
@@ -104,7 +104,7 @@ def test_invalid_notification_configuration(run_module, admin_user, organization
def test_deprecated_to_modern_no_op(run_module, admin_user, organization):
nt_config = {'url': 'http://www.example.com/hook', 'headers': {'X-Custom-Header': 'value123'}}
result = run_module(
'tower_notification_template',
'notification_template',
dict(
name='foo-notification-template',
organization=organization.name,
@@ -117,7 +117,7 @@ def test_deprecated_to_modern_no_op(run_module, admin_user, organization):
assert result.pop('changed', None), result
result = run_module(
'tower_notification_template',
'notification_template',
dict(
name='foo-notification-template',
organization=organization.name,
@@ -142,7 +142,7 @@ def test_build_notification_message_undefined(run_module, admin_user, organizati
custom_start_template = {'body': '{"started_by": "{{ job.summary_fields.created_by.username | default(\'My Placeholder\') }}"}'}
messages = {'started': custom_start_template, 'success': None, 'error': None, 'workflow_approval': None}
result = run_module(
'tower_notification_template',
'notification_template',
dict(
name='foo-notification-template',
organization=organization.name,

View File

@@ -23,7 +23,7 @@ def test_create_organization(run_module, admin_user):
'tower_config_file': None,
}
result = run_module('tower_organization', module_args, admin_user)
result = run_module('organization', module_args, admin_user)
assert result.get('changed'), result
org = Organization.objects.get(name='foo')

View File

@@ -10,7 +10,7 @@ from awx.main.models import Project
@pytest.mark.django_db
def test_create_project(run_module, admin_user, organization, silence_warning):
result = run_module(
'tower_project',
'project',
dict(name='foo', organization=organization.name, scm_type='git', scm_url='https://foo.invalid', wait=False, scm_update_cache_timeout=5),
admin_user,
)

View File

@@ -14,7 +14,7 @@ def test_grant_organization_permission(run_module, admin_user, organization, sta
if state == 'absent':
organization.admin_role.members.add(rando)
result = run_module('tower_role', {'user': rando.username, 'organization': organization.name, 'role': 'admin', 'state': state}, admin_user)
result = run_module('role', {'user': rando.username, 'organization': organization.name, 'role': 'admin', 'state': state}, admin_user)
assert not result.get('failed', False), result.get('msg', result)
if state == 'present':
@@ -31,7 +31,7 @@ def test_grant_workflow_permission(run_module, admin_user, organization, state):
if state == 'absent':
wfjt.execute_role.members.add(rando)
result = run_module('tower_role', {'user': rando.username, 'workflow': wfjt.name, 'role': 'execute', 'state': state}, admin_user)
result = run_module('role', {'user': rando.username, 'workflow': wfjt.name, 'role': 'execute', 'state': state}, admin_user)
assert not result.get('failed', False), result.get('msg', result)
if state == 'present':
@@ -49,7 +49,7 @@ def test_grant_workflow_list_permission(run_module, admin_user, organization, st
wfjt.execute_role.members.add(rando)
result = run_module(
'tower_role',
'role',
{'user': rando.username, 'lookup_organization': wfjt.organization.name, 'workflows': [wfjt.name], 'role': 'execute', 'state': state},
admin_user,
)
@@ -69,7 +69,7 @@ def test_grant_workflow_approval_permission(run_module, admin_user, organization
if state == 'absent':
wfjt.execute_role.members.add(rando)
result = run_module('tower_role', {'user': rando.username, 'workflow': wfjt.name, 'role': 'approval', 'state': state}, admin_user)
result = run_module('role', {'user': rando.username, 'workflow': wfjt.name, 'role': 'approval', 'state': state}, admin_user)
assert not result.get('failed', False), result.get('msg', result)
if state == 'present':
@@ -81,7 +81,7 @@ def test_grant_workflow_approval_permission(run_module, admin_user, organization
@pytest.mark.django_db
def test_invalid_role(run_module, admin_user, project):
rando = User.objects.create(username='rando')
result = run_module('tower_role', {'user': rando.username, 'project': project.name, 'role': 'adhoc', 'state': 'present'}, admin_user)
result = run_module('role', {'user': rando.username, 'project': project.name, 'role': 'adhoc', 'state': 'present'}, admin_user)
assert result.get('failed', False)
msg = result.get('msg')
assert 'has no role adhoc_role' in msg

View File

@@ -13,7 +13,7 @@ from awx.api.serializers import SchedulePreviewSerializer
@pytest.mark.django_db
def test_create_schedule(run_module, job_template, admin_user):
my_rrule = 'DTSTART;TZID=Zulu:20200416T034507 RRULE:FREQ=MONTHLY;INTERVAL=1'
result = run_module('tower_schedule', {'name': 'foo_schedule', 'unified_job_template': job_template.name, 'rrule': my_rrule}, admin_user)
result = run_module('schedule', {'name': 'foo_schedule', 'unified_job_template': job_template.name, 'rrule': my_rrule}, admin_user)
assert not result.get('failed', False), result.get('msg', result)
schedule = Schedule.objects.filter(name='foo_schedule').first()
@@ -68,7 +68,7 @@ def test_create_schedule(run_module, job_template, admin_user):
],
)
def test_rrule_lookup_plugin(collection_import, freq, kwargs, expect):
LookupModule = collection_import('plugins.lookup.tower_schedule_rrule').LookupModule
LookupModule = collection_import('plugins.lookup.schedule_rrule').LookupModule
generated_rule = LookupModule.get_rrule(freq, kwargs)
assert generated_rule == expect
rrule_checker = SchedulePreviewSerializer()
@@ -79,7 +79,7 @@ def test_rrule_lookup_plugin(collection_import, freq, kwargs, expect):
@pytest.mark.parametrize("freq", ('none', 'minute', 'hour', 'day', 'week', 'month'))
def test_empty_schedule_rrule(collection_import, freq):
LookupModule = collection_import('plugins.lookup.tower_schedule_rrule').LookupModule
LookupModule = collection_import('plugins.lookup.schedule_rrule').LookupModule
if freq == 'day':
pfreq = 'DAILY'
elif freq == 'none':
@@ -123,7 +123,7 @@ def test_empty_schedule_rrule(collection_import, freq):
],
)
def test_rrule_lookup_plugin_failure(collection_import, freq, kwargs, msg):
LookupModule = collection_import('plugins.lookup.tower_schedule_rrule').LookupModule
LookupModule = collection_import('plugins.lookup.schedule_rrule').LookupModule
with pytest.raises(AnsibleError) as e:
assert LookupModule.get_rrule(freq, kwargs)
assert msg in str(e.value)

View File

@@ -30,7 +30,7 @@ def test_receive_send_jt(run_module, admin_user, mocker, silence_deprecation):
jt.admin_role.members.add(admin_user) # work around send/receive bug
# receive everything
result = run_module('tower_receive', dict(all=True), admin_user)
result = run_module('receive', dict(all=True), admin_user)
assert 'assets' in result, result
assets = result['assets']
@@ -47,7 +47,7 @@ def test_receive_send_jt(run_module, admin_user, mocker, silence_deprecation):
# recreate everything
with mocker.patch('sys.stdin.isatty', return_value=True):
with mocker.patch('tower_cli.models.base.MonitorableResource.wait'):
result = run_module('tower_send', dict(assets=json.dumps(assets)), admin_user)
result = run_module('send', dict(assets=json.dumps(assets)), admin_user)
assert not result.get('failed'), result

View File

@@ -10,7 +10,7 @@ from awx.conf.models import Setting
@pytest.mark.django_db
def test_setting_flat_value(run_module, admin_user):
the_value = 'CN=service_account,OU=ServiceAccounts,DC=domain,DC=company,DC=org'
result = run_module('tower_settings', dict(name='AUTH_LDAP_BIND_DN', value=the_value), admin_user)
result = run_module('settings', dict(name='AUTH_LDAP_BIND_DN', value=the_value), admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert result.get('changed'), result
@@ -20,7 +20,7 @@ def test_setting_flat_value(run_module, admin_user):
@pytest.mark.django_db
def test_setting_dict_value(run_module, admin_user):
the_value = {'email': 'mail', 'first_name': 'givenName', 'last_name': 'surname'}
result = run_module('tower_settings', dict(name='AUTH_LDAP_USER_ATTR_MAP', value=the_value), admin_user)
result = run_module('settings', dict(name='AUTH_LDAP_USER_ATTR_MAP', value=the_value), admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert result.get('changed'), result
@@ -30,7 +30,7 @@ def test_setting_dict_value(run_module, admin_user):
@pytest.mark.django_db
def test_setting_nested_type(run_module, admin_user):
the_value = {'email': 'mail', 'first_name': 'givenName', 'last_name': 'surname'}
result = run_module('tower_settings', dict(settings={'AUTH_LDAP_USER_ATTR_MAP': the_value}), admin_user)
result = run_module('settings', dict(settings={'AUTH_LDAP_USER_ATTR_MAP': the_value}), admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert result.get('changed'), result
@@ -40,7 +40,7 @@ def test_setting_nested_type(run_module, admin_user):
@pytest.mark.django_db
def test_setting_bool_value(run_module, admin_user):
for the_value in (True, False):
result = run_module('tower_settings', dict(name='ACTIVITY_STREAM_ENABLED_FOR_INVENTORY_SYNC', value=the_value), admin_user)
result = run_module('settings', dict(name='ACTIVITY_STREAM_ENABLED_FOR_INVENTORY_SYNC', value=the_value), admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert result.get('changed'), result

View File

@@ -11,7 +11,7 @@ from awx.main.models import Organization, Team
def test_create_team(run_module, admin_user):
org = Organization.objects.create(name='foo')
result = run_module('tower_team', {'name': 'foo_team', 'description': 'fooin around', 'state': 'present', 'organization': 'foo'}, admin_user)
result = run_module('team', {'name': 'foo_team', 'description': 'fooin around', 'state': 'present', 'organization': 'foo'}, admin_user)
team = Team.objects.filter(name='foo_team').first()
@@ -32,7 +32,7 @@ def test_modify_team(run_module, admin_user):
team = Team.objects.create(name='foo_team', organization=org, description='flat foo')
assert team.description == 'flat foo'
result = run_module('tower_team', {'name': 'foo_team', 'description': 'fooin around', 'organization': 'foo'}, admin_user)
result = run_module('team', {'name': 'foo_team', 'description': 'fooin around', 'organization': 'foo'}, admin_user)
team.refresh_from_db()
result.pop('invocation')
assert result == {
@@ -42,6 +42,6 @@ def test_modify_team(run_module, admin_user):
assert team.description == 'fooin around'
# 2nd modification, should cause no change
result = run_module('tower_team', {'name': 'foo_team', 'description': 'fooin around', 'organization': 'foo'}, admin_user)
result = run_module('team', {'name': 'foo_team', 'description': 'fooin around', 'organization': 'foo'}, admin_user)
result.pop('invocation')
assert result == {"id": team.id, "changed": False}

View File

@@ -22,7 +22,7 @@ def test_create_token(run_module, admin_user):
'tower_config_file': None,
}
result = run_module('tower_token', module_args, admin_user)
result = run_module('token', module_args, admin_user)
assert result.get('changed'), result
tokens = OAuth2AccessToken.objects.filter(description='barfoo')

View File

@@ -20,7 +20,7 @@ def mock_auth_stuff():
@pytest.mark.django_db
def test_create_user(run_module, admin_user, mock_auth_stuff):
result = run_module('tower_user', dict(username='Bob', password='pass4word'), admin_user)
result = run_module('user', dict(username='Bob', password='pass4word'), admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert result.get('changed'), result
@@ -31,7 +31,7 @@ def test_create_user(run_module, admin_user, mock_auth_stuff):
@pytest.mark.django_db
def test_password_no_op_warning(run_module, admin_user, mock_auth_stuff, silence_warning):
for i in range(2):
result = run_module('tower_user', dict(username='Bob', password='pass4word'), admin_user)
result = run_module('user', dict(username='Bob', password='pass4word'), admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert result.get('changed') # not actually desired, but assert for sanity
@@ -44,7 +44,7 @@ def test_password_no_op_warning(run_module, admin_user, mock_auth_stuff, silence
@pytest.mark.django_db
def test_update_password_on_create(run_module, admin_user, mock_auth_stuff):
for i in range(2):
result = run_module('tower_user', dict(username='Bob', password='pass4word', update_secrets=False), admin_user)
result = run_module('user', dict(username='Bob', password='pass4word', update_secrets=False), admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert not result.get('changed')
@@ -52,11 +52,11 @@ def test_update_password_on_create(run_module, admin_user, mock_auth_stuff):
@pytest.mark.django_db
def test_update_user(run_module, admin_user, mock_auth_stuff):
result = run_module('tower_user', dict(username='Bob', password='pass4word', is_system_auditor=True), admin_user)
result = run_module('user', dict(username='Bob', password='pass4word', is_system_auditor=True), admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert result.get('changed'), result
update_result = run_module('tower_user', dict(username='Bob', is_system_auditor=False), admin_user)
update_result = run_module('user', dict(username='Bob', is_system_auditor=False), admin_user)
assert update_result.get('changed')
user = User.objects.get(id=result['id'])

View File

@@ -10,7 +10,7 @@ from awx.main.models import WorkflowJobTemplate, NotificationTemplate
@pytest.mark.django_db
def test_create_workflow_job_template(run_module, admin_user, organization, survey_spec):
result = run_module(
'tower_workflow_job_template',
'workflow_job_template',
{
'name': 'foo-workflow',
'organization': organization.name,
@@ -35,7 +35,7 @@ def test_create_workflow_job_template(run_module, admin_user, organization, surv
@pytest.mark.django_db
def test_create_modify_no_survey(run_module, admin_user, organization, survey_spec):
result = run_module('tower_workflow_job_template', {'name': 'foo-workflow', 'organization': organization.name}, admin_user)
result = run_module('workflow_job_template', {'name': 'foo-workflow', 'organization': organization.name}, admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert result.get('changed', False), result
@@ -45,7 +45,7 @@ def test_create_modify_no_survey(run_module, admin_user, organization, survey_sp
result.pop('invocation', None)
assert result == {"name": "foo-workflow", "id": wfjt.id, "changed": True}
result = run_module('tower_workflow_job_template', {'name': 'foo-workflow', 'organization': organization.name}, admin_user)
result = run_module('workflow_job_template', {'name': 'foo-workflow', 'organization': organization.name}, admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert not result.get('changed', True), result
@@ -53,7 +53,7 @@ def test_create_modify_no_survey(run_module, admin_user, organization, survey_sp
@pytest.mark.django_db
def test_survey_spec_only_changed(run_module, admin_user, organization, survey_spec):
wfjt = WorkflowJobTemplate.objects.create(organization=organization, name='foo-workflow', survey_enabled=True, survey_spec=survey_spec)
result = run_module('tower_workflow_job_template', {'name': 'foo-workflow', 'organization': organization.name, 'state': 'present'}, admin_user)
result = run_module('workflow_job_template', {'name': 'foo-workflow', 'organization': organization.name, 'state': 'present'}, admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert not result.get('changed', True), result
wfjt.refresh_from_db()
@@ -62,7 +62,7 @@ def test_survey_spec_only_changed(run_module, admin_user, organization, survey_s
survey_spec['description'] = 'changed description'
result = run_module(
'tower_workflow_job_template', {'name': 'foo-workflow', 'organization': organization.name, 'survey_spec': survey_spec, 'state': 'present'}, admin_user
'workflow_job_template', {'name': 'foo-workflow', 'organization': organization.name, 'survey_spec': survey_spec, 'state': 'present'}, admin_user
)
assert not result.get('failed', False), result.get('msg', result)
assert result.get('changed', True), result
@@ -73,7 +73,7 @@ def test_survey_spec_only_changed(run_module, admin_user, organization, survey_s
@pytest.mark.django_db
def test_survey_spec_only_changed(run_module, admin_user, organization, survey_spec):
wfjt = WorkflowJobTemplate.objects.create(organization=organization, name='foo-workflow', survey_enabled=True, survey_spec=survey_spec)
result = run_module('tower_workflow_job_template', {'name': 'foo-workflow', 'organization': organization.name, 'state': 'present'}, admin_user)
result = run_module('workflow_job_template', {'name': 'foo-workflow', 'organization': organization.name, 'state': 'present'}, admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert not result.get('changed', True), result
wfjt.refresh_from_db()
@@ -82,7 +82,7 @@ def test_survey_spec_only_changed(run_module, admin_user, organization, survey_s
del survey_spec['description']
result = run_module(
'tower_workflow_job_template', {'name': 'foo-workflow', 'organization': organization.name, 'survey_spec': survey_spec, 'state': 'present'}, admin_user
'workflow_job_template', {'name': 'foo-workflow', 'organization': organization.name, 'survey_spec': survey_spec, 'state': 'present'}, admin_user
)
assert result.get('failed', True)
assert result.get('msg') == "Failed to update survey: Field 'description' is missing from survey spec."
@@ -107,7 +107,7 @@ def test_associate_only_on_success(run_module, admin_user, organization, project
# test preservation of error NTs when success NTs are added
result = run_module(
'tower_workflow_job_template', {'name': 'foo-workflow', 'organization': organization.name, 'notification_templates_success': ['nt2']}, admin_user
'workflow_job_template', {'name': 'foo-workflow', 'organization': organization.name, 'notification_templates_success': ['nt2']}, admin_user
)
assert not result.get('failed', False), result.get('msg', result)
assert result.get('changed', True), result
@@ -116,9 +116,7 @@ def test_associate_only_on_success(run_module, admin_user, organization, project
assert list(wfjt.notification_templates_error.values_list('id', flat=True)) == [nt1.id]
# test removal to empty list
result = run_module(
'tower_workflow_job_template', {'name': 'foo-workflow', 'organization': organization.name, 'notification_templates_success': []}, admin_user
)
result = run_module('workflow_job_template', {'name': 'foo-workflow', 'organization': organization.name, 'notification_templates_success': []}, admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert result.get('changed', True), result
@@ -129,7 +127,7 @@ def test_associate_only_on_success(run_module, admin_user, organization, project
@pytest.mark.django_db
def test_delete_with_spec(run_module, admin_user, organization, survey_spec):
WorkflowJobTemplate.objects.create(organization=organization, name='foo-workflow', survey_enabled=True, survey_spec=survey_spec)
result = run_module('tower_workflow_job_template', {'name': 'foo-workflow', 'organization': organization.name, 'state': 'absent'}, admin_user)
result = run_module('workflow_job_template', {'name': 'foo-workflow', 'organization': organization.name, 'state': 'absent'}, admin_user)
assert not result.get('failed', False), result.get('msg', result)
assert result.get('changed', True), result

View File

@@ -31,7 +31,7 @@ def wfjt(organization):
def test_create_workflow_job_template_node(run_module, admin_user, wfjt, job_template):
this_identifier = '42🐉'
result = run_module(
'tower_workflow_job_template_node',
'workflow_job_template_node',
{
'identifier': this_identifier,
'workflow_job_template': 'foo-workflow',
@@ -58,7 +58,7 @@ def test_create_workflow_job_template_node_approval_node(run_module, admin_user,
"""This is a part of the API contract for creating approval nodes"""
this_identifier = '42🐉'
result = run_module(
'tower_workflow_job_template_node',
'workflow_job_template_node',
{
'identifier': this_identifier,
'workflow_job_template': wfjt.name,
@@ -83,7 +83,7 @@ def test_create_workflow_job_template_node_approval_node(run_module, admin_user,
@pytest.mark.django_db
def test_make_use_of_prompts(run_module, admin_user, wfjt, job_template, machine_credential, vault_credential):
result = run_module(
'tower_workflow_job_template_node',
'workflow_job_template_node',
{
'identifier': '42',
'workflow_job_template': 'foo-workflow',
@@ -113,7 +113,7 @@ def test_create_with_edges(run_module, admin_user, wfjt, job_template):
]
result = run_module(
'tower_workflow_job_template_node',
'workflow_job_template_node',
{
'identifier': '42',
'workflow_job_template': 'foo-workflow',

View File

@@ -10,7 +10,7 @@ from awx.main.models import WorkflowJobTemplate, JobTemplate, Project, Inventory
@pytest.mark.django_db
def test_create_workflow_job_template(run_module, admin_user, organization, survey_spec, silence_deprecation):
result = run_module(
'tower_workflow_template',
'workflow_template',
{
'name': 'foo-workflow',
'organization': organization.name,
@@ -37,7 +37,7 @@ def test_with_nested_workflow(run_module, admin_user, organization, silence_depr
wfjt1 = WorkflowJobTemplate.objects.create(name='first', organization=organization)
result = run_module(
'tower_workflow_template',
'workflow_template',
{'name': 'foo-workflow', 'organization': organization.name, 'schema': [{'workflow': wfjt1.name}], 'state': 'present'},
admin_user,
)
@@ -58,7 +58,7 @@ def test_schema_with_branches(run_module, admin_user, organization, silence_depr
inv_src = InventorySource.objects.create(inventory=inv, name='AWS servers', source='ec2')
result = run_module(
'tower_workflow_template',
'workflow_template',
{
'name': 'foo-workflow',
'organization': organization.name,
@@ -96,7 +96,7 @@ def test_schema_with_branches(run_module, admin_user, organization, silence_depr
@pytest.mark.django_db
def test_with_missing_ujt(run_module, admin_user, organization, silence_deprecation):
result = run_module(
'tower_workflow_template', {'name': 'foo-workflow', 'organization': organization.name, 'schema': [{'foo': 'bar'}], 'state': 'present'}, admin_user
'workflow_template', {'name': 'foo-workflow', 'organization': organization.name, 'schema': [{'foo': 'bar'}], 'state': 'present'}, admin_user
)
assert result.get('failed', False), result
assert 'You should provide exactly one of the attributes job_template,' in result['msg']