mirror of
https://github.com/ansible/awx.git
synced 2026-06-25 08:28:03 -02:30
Register CredentialType(s) every time Django loads
* Register all discovered CredentialType(s) after Django finishes loading * Protect parallel registrations using shared postgres advisory lock * The down-side of this is that this will run when it does not need to, adding overhead to the init process. * Only register discovered credential types in the database IF migrations have ran and are up-to-date.
This commit is contained in:
committed by
Chris Meyers
parent
71856d61c9
commit
490db08224
26
awx/main/tests/functional/test_apps.py
Normal file
26
awx/main/tests/functional/test_apps.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import pytest
|
||||
|
||||
from django.apps import apps
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_setup_tower_managed_defaults(mocker):
|
||||
return mocker.patch('awx.main.models.credential.CredentialType.setup_tower_managed_defaults')
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_load_credential_types_feature_migrations_ran(mocker, mock_setup_tower_managed_defaults):
|
||||
mocker.patch('awx.main.apps.is_database_synchronized', return_value=True)
|
||||
|
||||
apps.get_app_config('main')._load_credential_types_feature()
|
||||
|
||||
mock_setup_tower_managed_defaults.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_load_credential_types_feature_migrations_not_ran(mocker, mock_setup_tower_managed_defaults):
|
||||
mocker.patch('awx.main.apps.is_database_synchronized', return_value=False)
|
||||
|
||||
apps.get_app_config('main')._load_credential_types_feature()
|
||||
|
||||
mock_setup_tower_managed_defaults.assert_not_called()
|
||||
Reference in New Issue
Block a user