mirror of
https://github.com/ansible/awx.git
synced 2026-02-04 02:58:13 -03:30
* 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.
27 lines
865 B
Python
27 lines
865 B
Python
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()
|