1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-30 05:25:29 +03:00

Fix test errors running locally with Ansible devel

This commit is contained in:
AlanCoding 2020-03-18 16:13:34 -04:00
parent 1fce77054a
commit 362016c91b
No known key found for this signature in database
GPG Key ID: FD2C3C012A72926B
4 changed files with 25 additions and 11 deletions

View File

@ -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

View File

@ -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')

View File

@ -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

View File

@ -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,