mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 11:27:36 -02:30
group -> deprecated_group, added migrations, added/removed tests
This commit is contained in:
@@ -4,10 +4,7 @@ from awx.api.versioning import reverse
|
||||
from django.test.client import RequestFactory
|
||||
|
||||
from awx.main.models import Role, Group, UnifiedJobTemplate, JobTemplate
|
||||
from awx.main.access import (
|
||||
access_registry,
|
||||
get_user_capabilities
|
||||
)
|
||||
from awx.main.access import access_registry
|
||||
from awx.main.utils import cache_list_capabilities
|
||||
from awx.api.serializers import JobTemplateSerializer
|
||||
|
||||
|
||||
45
awx/main/tests/functional/test_inventory_source_migration.py
Normal file
45
awx/main/tests/functional/test_inventory_source_migration.py
Normal file
@@ -0,0 +1,45 @@
|
||||
import pytest
|
||||
|
||||
from awx.main.migrations import _inventory_source as invsrc
|
||||
from awx.main.models import InventorySource
|
||||
|
||||
from django.apps import apps
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_inv_src_manual_removal(inventory_source):
|
||||
inventory_source.source = ''
|
||||
inventory_source.save()
|
||||
|
||||
assert InventorySource.objects.filter(pk=inventory_source.pk).exists()
|
||||
invsrc.remove_manual_inventory_sources(apps, None)
|
||||
assert not InventorySource.objects.filter(pk=inventory_source.pk).exists()
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_inv_src_rename(inventory_source_factory):
|
||||
inv_src01 = inventory_source_factory('t1')
|
||||
|
||||
invsrc.rename_inventory_sources(apps, None)
|
||||
|
||||
inv_src01.refresh_from_db()
|
||||
# inv-is-t1 is generated in the inventory_source_factory
|
||||
assert inv_src01.name == 't1 - inv-is-t1 - 0'
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_inv_src_nolink_removal(inventory_source_factory):
|
||||
inventory_source_factory('t1')
|
||||
inv_src02 = inventory_source_factory('t2')
|
||||
|
||||
inv_src02.inventory = None
|
||||
inv_src02.deprecated_group = None
|
||||
inv_src02.save()
|
||||
|
||||
assert InventorySource.objects.count() == 2
|
||||
|
||||
invsrc.remove_inventory_source_with_no_inventory_link(apps, None)
|
||||
|
||||
objs = InventorySource.objects.all()
|
||||
assert len(objs) == 1
|
||||
assert 't1' in objs[0].name
|
||||
Reference in New Issue
Block a user