mirror of
https://github.com/ansible/awx.git
synced 2026-02-15 02:00:01 -03:30
fixes config endpoint performance issue
This commit is contained in:
6
awx/main/tests/unit/settings/test_development.py
Normal file
6
awx/main/tests/unit/settings/test_development.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
def test_ANSILE_VERSION(mocker):
|
||||||
|
from django.conf import settings
|
||||||
|
assert hasattr(settings, 'ANSIBLE_VERSION')
|
||||||
|
|
||||||
20
awx/main/tests/unit/test_utils.py
Normal file
20
awx/main/tests/unit/test_utils.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import pytest
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from awx.main.utils import get_ansible_version
|
||||||
|
|
||||||
|
def test_dev(mocker, settings):
|
||||||
|
settings.ANSIBLE_VERSION = mocker.Mock()
|
||||||
|
|
||||||
|
res = get_ansible_version()
|
||||||
|
|
||||||
|
assert res == settings.ANSIBLE_VERSION
|
||||||
|
|
||||||
|
def test_production(mocker, settings):
|
||||||
|
mock_Popen = mocker.MagicMock()
|
||||||
|
mocker.patch.object(subprocess, 'Popen', mock_Popen)
|
||||||
|
del settings.ANSIBLE_VERSION
|
||||||
|
|
||||||
|
get_ansible_version()
|
||||||
|
|
||||||
|
mock_Popen.assert_called_with(['ansible', '--version'], stdout=subprocess.PIPE)
|
||||||
@@ -97,6 +97,9 @@ def get_ansible_version():
|
|||||||
'''
|
'''
|
||||||
Return Ansible version installed.
|
Return Ansible version installed.
|
||||||
'''
|
'''
|
||||||
|
from django.conf import settings
|
||||||
|
if hasattr(settings, 'ANSIBLE_VERSION'):
|
||||||
|
return settings.ANSIBLE_VERSION
|
||||||
try:
|
try:
|
||||||
proc = subprocess.Popen(['ansible', '--version'],
|
proc = subprocess.Popen(['ansible', '--version'],
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE)
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import traceback
|
|||||||
# Django Split Settings
|
# Django Split Settings
|
||||||
from split_settings.tools import optional, include
|
from split_settings.tools import optional, include
|
||||||
|
|
||||||
|
from awx.main.utils import get_ansible_version
|
||||||
|
|
||||||
# Load default settings.
|
# Load default settings.
|
||||||
from defaults import * # NOQA
|
from defaults import * # NOQA
|
||||||
|
|
||||||
@@ -33,6 +35,8 @@ AWX_PROOT_ENABLED = True
|
|||||||
|
|
||||||
PENDO_TRACKING_STATE = "off"
|
PENDO_TRACKING_STATE = "off"
|
||||||
|
|
||||||
|
ANSIBLE_VERSION = get_ansible_version()
|
||||||
|
|
||||||
# Use Django-Jenkins if installed. Only run tests for awx.main app.
|
# Use Django-Jenkins if installed. Only run tests for awx.main app.
|
||||||
try:
|
try:
|
||||||
import django_jenkins
|
import django_jenkins
|
||||||
|
|||||||
Reference in New Issue
Block a user