diff --git a/awx_collection/test/awx/conftest.py b/awx_collection/test/awx/conftest.py index a6c5a6cea1..c8856aa82b 100644 --- a/awx_collection/test/awx/conftest.py +++ b/awx_collection/test/awx/conftest.py @@ -209,3 +209,19 @@ def vault_credential(organization): credential_type=ct, name='vault-cred', inputs={'vault_id': 'foo', 'vault_password': 'pas4word'} ) + + +@pytest.fixture +def silence_deprecation(): + """The deprecation warnings are stored in a global variable + they will create cross-test interference. Use this to turn them off. + """ + with mock.patch('ansible.module_utils.basic.AnsibleModule.deprecate'): + yield + + +@pytest.fixture +def silence_warning(): + """Warnings use global variable, same as deprecations.""" + with mock.patch('ansible.module_utils.basic.AnsibleModule.warn'): + yield diff --git a/awx_collection/test/awx/test_role.py b/awx_collection/test/awx/test_role.py index 8377bc3e38..464a474b0a 100644 --- a/awx_collection/test/awx/test_role.py +++ b/awx_collection/test/awx/test_role.py @@ -7,7 +7,7 @@ from awx.main.models import WorkflowJobTemplate, User @pytest.mark.django_db -def test_grant_organization_permission(run_module, admin_user, organization): +def test_grant_organization_permission(run_module, admin_user, organization, silence_deprecation): rando = User.objects.create(username='rando') result = run_module('tower_role', { @@ -22,7 +22,7 @@ def test_grant_organization_permission(run_module, admin_user, organization): @pytest.mark.django_db -def test_grant_workflow_permission(run_module, admin_user, organization): +def test_grant_workflow_permission(run_module, admin_user, organization, silence_deprecation): wfjt = WorkflowJobTemplate.objects.create(organization=organization, name='foo-workflow') rando = User.objects.create(username='rando') diff --git a/awx_collection/test/awx/test_send_receive.py b/awx_collection/test/awx/test_send_receive.py index 01cad4ae38..c907e185eb 100644 --- a/awx_collection/test/awx/test_send_receive.py +++ b/awx_collection/test/awx/test_send_receive.py @@ -2,7 +2,6 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type import pytest -from unittest import mock import json from awx.main.models import ( @@ -16,8 +15,9 @@ from awx.main.models import ( ) +# warns based on password_management param, but not security issue @pytest.mark.django_db -def test_receive_send_jt(run_module, admin_user, mocker): +def test_receive_send_jt(run_module, admin_user, mocker, silence_deprecation, silence_warning): org = Organization.objects.create(name='SRtest') proj = Project.objects.create( name='SRtest', @@ -66,9 +66,7 @@ def test_receive_send_jt(run_module, admin_user, mocker): # recreate everything with mocker.patch('sys.stdin.isatty', return_value=True): with mocker.patch('tower_cli.models.base.MonitorableResource.wait'): - # warns based on password_management param, but not security issue - with mock.patch('ansible.module_utils.basic.AnsibleModule.warn'): - result = run_module('tower_send', dict(assets=json.dumps(assets)), admin_user) + result = run_module('tower_send', dict(assets=json.dumps(assets)), admin_user) assert not result.get('failed'), result diff --git a/awx_collection/test/awx/test_workflow_template.py b/awx_collection/test/awx/test_workflow_template.py index e58a5d5d92..9665d315b7 100644 --- a/awx_collection/test/awx/test_workflow_template.py +++ b/awx_collection/test/awx/test_workflow_template.py @@ -10,7 +10,7 @@ from awx.main.models import ( @pytest.mark.django_db -def test_create_workflow_job_template(run_module, admin_user, organization): +def test_create_workflow_job_template(run_module, admin_user, organization, silence_deprecation): module_args = { 'name': 'foo-workflow', @@ -39,7 +39,7 @@ def test_create_workflow_job_template(run_module, admin_user, organization): @pytest.mark.django_db -def test_with_nested_workflow(run_module, admin_user, organization): +def test_with_nested_workflow(run_module, admin_user, organization, silence_deprecation): wfjt1 = WorkflowJobTemplate.objects.create(name='first', organization=organization) result = run_module('tower_workflow_template', { @@ -59,7 +59,7 @@ def test_with_nested_workflow(run_module, admin_user, organization): @pytest.mark.django_db -def test_schema_with_branches(run_module, admin_user, organization): +def test_schema_with_branches(run_module, admin_user, organization, silence_deprecation): proj = Project.objects.create(organization=organization, name='Ansible Examples') inv = Inventory.objects.create(organization=organization, name='test-inv') @@ -119,7 +119,7 @@ def test_schema_with_branches(run_module, admin_user, organization): @pytest.mark.django_db -def test_with_missing_ujt(run_module, admin_user, organization): +def test_with_missing_ujt(run_module, admin_user, organization, silence_deprecation): result = run_module('tower_workflow_template', { 'name': 'foo-workflow', 'organization': organization.name,