diff options
author | Sean Sullivan <ssulliva@redhat.com> | 2021-01-17 05:58:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-17 05:58:41 +0100 |
commit | 1ce9c00d77b3d11d4d7744082f51398c4f199567 (patch) | |
tree | 61aa3441e9ccc104a467fcba92c0854ef0b0deef /awx_collection | |
parent | Merge pull request #23 from ansible/devel (diff) | |
parent | Merge pull request #9099 from rooftopcellist/rm_launch_configmap (diff) | |
download | awx-1ce9c00d77b3d11d4d7744082f51398c4f199567.tar.xz awx-1ce9c00d77b3d11d4d7744082f51398c4f199567.zip |
Merge pull request #26 from ansible/devel
Rebase
Diffstat (limited to 'awx_collection')
4 files changed, 35 insertions, 6 deletions
diff --git a/awx_collection/plugins/modules/tower_project.py b/awx_collection/plugins/modules/tower_project.py index 3e6d6ab442..ca848e7d69 100644 --- a/awx_collection/plugins/modules/tower_project.py +++ b/awx_collection/plugins/modules/tower_project.py @@ -153,7 +153,7 @@ EXAMPLES = ''' organization: "test" scm_update_on_launch: True scm_update_cache_timeout: 60 - custom_virtualenv: "/var/lib/awx/venv/ansible-2.2" + custom_virtualenv: "/var/lib/awx/var/lib/awx/venv/ansible-2.2" state: present tower_config_file: "~/tower_cli.cfg" ''' diff --git a/awx_collection/test/awx/test_inventory_source.py b/awx_collection/test/awx/test_inventory_source.py index 1bced2eb67..3e65feaddb 100644 --- a/awx_collection/test/awx/test_inventory_source.py +++ b/awx_collection/test/awx/test_inventory_source.py @@ -133,10 +133,10 @@ def test_custom_venv_no_op(run_module, admin_user, base_inventory, mocker, proje inventory=base_inventory, source_project=project, source='scm', - custom_virtualenv='/venv/foobar/' + custom_virtualenv='/var/lib/awx/venv/foobar/' ) # mock needed due to API behavior, not incorrect client behavior - with mocker.patch('awx.main.models.mixins.get_custom_venv_choices', return_value=['/venv/foobar/']): + with mocker.patch('awx.main.models.mixins.get_custom_venv_choices', return_value=['/var/lib/awx/venv/foobar/']): result = run_module('tower_inventory_source', dict( name='foo', description='this is the changed description', @@ -148,7 +148,7 @@ def test_custom_venv_no_op(run_module, admin_user, base_inventory, mocker, proje ), admin_user) assert result.pop('changed', None), result inv_src.refresh_from_db() - assert inv_src.custom_virtualenv == '/venv/foobar/' + assert inv_src.custom_virtualenv == '/var/lib/awx/venv/foobar/' assert inv_src.description == 'this is the changed description' diff --git a/awx_collection/test/awx/test_notification_template.py b/awx_collection/test/awx/test_notification_template.py index 28f7c4ecee..96fbd5e56c 100644 --- a/awx_collection/test/awx/test_notification_template.py +++ b/awx_collection/test/awx/test_notification_template.py @@ -3,7 +3,7 @@ __metaclass__ = type import pytest -from awx.main.models import NotificationTemplate +from awx.main.models import NotificationTemplate, Job def compare_with_encrypted(model_config, param_config): @@ -109,3 +109,32 @@ def test_deprecated_to_modern_no_op(run_module, admin_user, organization): ), admin_user) assert not result.get('failed', False), result.get('msg', result) assert not result.pop('changed', None), result + + +@pytest.mark.django_db +def test_build_notification_message_undefined(run_module, admin_user, organization): + """Job notification templates may encounter undefined values in the context when they are + rendered. Make sure that accessing attributes or items of an undefined value returns another + instance of Undefined, rather than raising an UndefinedError. This enables the use of expressions + like "{{ job.created_by.first_name | default('unknown') }}".""" + job = Job.objects.create(name='foobar') + + nt_config = { + 'url': 'http://www.example.com/hook', + 'headers': { + 'X-Custom-Header': 'value123' + } + } + 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', dict( + name='foo-notification-template', + organization=organization.name, + notification_type='webhook', + notification_configuration=nt_config, + messages=messages, + ), admin_user) + nt = NotificationTemplate.objects.get(id=result['id']) + + _, body = job.build_notification_message(nt, 'running') + assert '{"started_by": "My Placeholder"}' in body diff --git a/awx_collection/tools/roles/template_galaxy/templates/README.md.j2 b/awx_collection/tools/roles/template_galaxy/templates/README.md.j2 index 8a5743d34f..ed02006c3d 100644 --- a/awx_collection/tools/roles/template_galaxy/templates/README.md.j2 +++ b/awx_collection/tools/roles/template_galaxy/templates/README.md.j2 @@ -31,7 +31,7 @@ with the current AWX version, for example: `awx_collection/awx-awx-9.2.0.tar.gz` Installing the `tar.gz` involves no special instructions. {% else %} -This collection should be installed from [Content Hub][https://cloud.redhat.com/ansible/automation-hub/ansible/tower/] +This collection should be installed from [Content Hub](https://cloud.redhat.com/ansible/automation-hub/ansible/tower/) {% endif %} ## Running |