mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 07:26:03 -03:30
Merge pull request #13875 from john-westcott-iv/fix_assumed_databases
Fixing issue were we assumed DATABASES would be defined
This commit is contained in:
23
awx/main/tests/functional/api/test_application_name.py
Normal file
23
awx/main/tests/functional/api/test_application_name.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import pytest
|
||||||
|
from awx.settings.application_name import get_service_name, set_application_name
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
'argv,result',
|
||||||
|
(
|
||||||
|
([], None),
|
||||||
|
(['-m'], None),
|
||||||
|
(['-m', 'python'], None),
|
||||||
|
(['-m', 'python', 'manage'], None),
|
||||||
|
(['-m', 'python', 'manage', 'a'], 'a'),
|
||||||
|
(['-m', 'python', 'manage', 'b', 'a'], 'b'),
|
||||||
|
(['-m', 'python', 'manage', 'run_something', 'b', 'a'], 'something'),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
def test_get_service_name(argv, result):
|
||||||
|
assert get_service_name(argv) == result
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('DATABASES,CLUSTER_ID,function', (({}, 12, ''), ({'default': {'ENGINE': 'sqllite3'}}, 12, '')))
|
||||||
|
def test_set_application_name(DATABASES, CLUSTER_ID, function):
|
||||||
|
set_application_name(DATABASES, CLUSTER_ID, function)
|
||||||
@@ -25,6 +25,10 @@ def get_application_name(CLUSTER_HOST_ID, function=''):
|
|||||||
|
|
||||||
|
|
||||||
def set_application_name(DATABASES, CLUSTER_HOST_ID, function=''):
|
def set_application_name(DATABASES, CLUSTER_HOST_ID, function=''):
|
||||||
|
# If settings files were not properly passed DATABASES could be {} at which point we don't need to set the app name.
|
||||||
|
if not DATABASES or 'default' not in DATABASES:
|
||||||
|
return
|
||||||
|
|
||||||
if 'sqlite3' in DATABASES['default']['ENGINE']:
|
if 'sqlite3' in DATABASES['default']['ENGINE']:
|
||||||
return
|
return
|
||||||
options_dict = DATABASES['default'].setdefault('OPTIONS', dict())
|
options_dict = DATABASES['default'].setdefault('OPTIONS', dict())
|
||||||
|
|||||||
Reference in New Issue
Block a user