1
- from django .conf import settings
2
- from awx .settings import REST_FRAMEWORK
3
- from awx .settings .functions import toggle_feature_flags , merge_application_name
4
-
5
1
LOCAL_SETTINGS = (
6
2
'ALLOWED_HOSTS' ,
7
3
'BROADCAST_WEBSOCKET_PORT' ,
18
14
19
15
def test_postprocess_auth_basic_enabled ():
20
16
"""The final loaded settings should have basic auth enabled."""
17
+ from awx .settings import REST_FRAMEWORK
18
+
21
19
assert 'awx.api.authentication.LoggedBasicAuthentication' in REST_FRAMEWORK ['DEFAULT_AUTHENTICATION_CLASSES' ]
22
20
23
21
24
22
def test_default_settings ():
25
23
"""Ensure that all default settings are present in the snapshot."""
24
+ from django .conf import settings
25
+
26
26
for k in dir (settings ):
27
27
if k not in settings .DEFAULTS_SNAPSHOT or k in LOCAL_SETTINGS :
28
28
continue
@@ -33,34 +33,35 @@ def test_default_settings():
33
33
34
34
def test_django_conf_settings_is_awx_settings ():
35
35
"""Ensure that the settings loaded from dynaconf are the same as the settings delivered to django."""
36
- assert settings .REST_FRAMEWORK is REST_FRAMEWORK
36
+ from django .conf import settings
37
+ from awx .settings import REST_FRAMEWORK
38
+
39
+ assert settings .REST_FRAMEWORK == REST_FRAMEWORK
37
40
38
41
39
42
def test_dynaconf_is_awx_settings ():
40
43
"""Ensure that the settings loaded from dynaconf are the same as the settings delivered to django."""
41
- assert settings .DYNACONF .REST_FRAMEWORK is REST_FRAMEWORK
44
+ from django .conf import settings
45
+ from awx .settings import REST_FRAMEWORK
42
46
47
+ assert settings .DYNACONF .REST_FRAMEWORK == REST_FRAMEWORK
43
48
44
- def test_production_settings_can_be_directly_imported ():
45
- """Ensure that the production settings can be directly imported."""
46
- from awx .settings .production import REST_FRAMEWORK
47
- from awx .settings .production import DEBUG
48
49
49
- assert settings .REST_FRAMEWORK is REST_FRAMEWORK
50
- assert DEBUG is False
51
-
52
-
53
- def test_development_settings_can_be_directly_imported ():
50
+ def test_development_settings_can_be_directly_imported (monkeypatch ):
54
51
"""Ensure that the development settings can be directly imported."""
52
+ monkeypatch .setenv ('AWX_MODE' , 'development' )
53
+ from django .conf import settings
55
54
from awx .settings .development import REST_FRAMEWORK
56
55
from awx .settings .development import DEBUG # actually set on defaults.py and not overridden in development.py
57
56
58
- assert settings .REST_FRAMEWORK is REST_FRAMEWORK
57
+ assert settings .REST_FRAMEWORK == REST_FRAMEWORK
59
58
assert DEBUG is True
60
59
61
60
62
61
def test_toggle_feature_flags ():
63
62
"""Ensure that the toggle_feature_flags function works as expected."""
63
+ from awx .settings .functions import toggle_feature_flags
64
+
64
65
settings = {
65
66
"FLAGS" : {
66
67
"FEATURE_SOME_PLATFORM_FLAG_ENABLED" : [
@@ -80,8 +81,12 @@ def test_toggle_feature_flags():
80
81
81
82
def test_merge_application_name ():
82
83
"""Ensure that the merge_application_name function works as expected."""
84
+ from awx .settings .functions import merge_application_name
85
+
83
86
settings = {
84
87
"DATABASES__default__ENGINE" : "django.db.backends.postgresql" ,
85
88
"CLUSTER_HOST_ID" : "test-cluster-host-id" ,
86
89
}
87
- assert merge_application_name (settings ) == {"DATABASES__default__OPTIONS__application_name" : "test-cluster-host-id" }
90
+ result = merge_application_name (settings )["DATABASES__default__OPTIONS__application_name" ]
91
+ assert result .startswith ("awx-" )
92
+ assert "test-cluster" in result
0 commit comments