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:
parent
1fce77054a
commit
362016c91b
@ -209,3 +209,19 @@ def vault_credential(organization):
|
|||||||
credential_type=ct, name='vault-cred',
|
credential_type=ct, name='vault-cred',
|
||||||
inputs={'vault_id': 'foo', 'vault_password': 'pas4word'}
|
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
|
||||||
|
@ -7,7 +7,7 @@ from awx.main.models import WorkflowJobTemplate, User
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@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')
|
rando = User.objects.create(username='rando')
|
||||||
|
|
||||||
result = run_module('tower_role', {
|
result = run_module('tower_role', {
|
||||||
@ -22,7 +22,7 @@ def test_grant_organization_permission(run_module, admin_user, organization):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@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')
|
wfjt = WorkflowJobTemplate.objects.create(organization=organization, name='foo-workflow')
|
||||||
rando = User.objects.create(username='rando')
|
rando = User.objects.create(username='rando')
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ from __future__ import (absolute_import, division, print_function)
|
|||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from unittest import mock
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from awx.main.models import (
|
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
|
@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')
|
org = Organization.objects.create(name='SRtest')
|
||||||
proj = Project.objects.create(
|
proj = Project.objects.create(
|
||||||
name='SRtest',
|
name='SRtest',
|
||||||
@ -66,8 +66,6 @@ def test_receive_send_jt(run_module, admin_user, mocker):
|
|||||||
# recreate everything
|
# recreate everything
|
||||||
with mocker.patch('sys.stdin.isatty', return_value=True):
|
with mocker.patch('sys.stdin.isatty', return_value=True):
|
||||||
with mocker.patch('tower_cli.models.base.MonitorableResource.wait'):
|
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
|
assert not result.get('failed'), result
|
||||||
|
@ -10,7 +10,7 @@ from awx.main.models import (
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@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 = {
|
module_args = {
|
||||||
'name': 'foo-workflow',
|
'name': 'foo-workflow',
|
||||||
@ -39,7 +39,7 @@ def test_create_workflow_job_template(run_module, admin_user, organization):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@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)
|
wfjt1 = WorkflowJobTemplate.objects.create(name='first', organization=organization)
|
||||||
|
|
||||||
result = run_module('tower_workflow_template', {
|
result = run_module('tower_workflow_template', {
|
||||||
@ -59,7 +59,7 @@ def test_with_nested_workflow(run_module, admin_user, organization):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@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')
|
proj = Project.objects.create(organization=organization, name='Ansible Examples')
|
||||||
inv = Inventory.objects.create(organization=organization, name='test-inv')
|
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
|
@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', {
|
result = run_module('tower_workflow_template', {
|
||||||
'name': 'foo-workflow',
|
'name': 'foo-workflow',
|
||||||
'organization': organization.name,
|
'organization': organization.name,
|
||||||
|
Loading…
Reference in New Issue
Block a user