mirror of
https://github.com/ansible/awx.git
synced 2026-02-17 03:00:04 -03:30
Inventory source file-type combined with a linked project will allow the inventory source to be updated when the project is updated. The inventory update runs in the post-run hook of the project update.
34 lines
1.3 KiB
Python
34 lines
1.3 KiB
Python
import pytest
|
|
import mock
|
|
|
|
# AWX
|
|
from awx.main.models import InventorySource, InventoryUpdate
|
|
|
|
|
|
@pytest.mark.django_db
|
|
class TestSCMUpdateFeatures:
|
|
|
|
def test_automatic_project_update_on_create(self, inventory, project):
|
|
inv_src = InventorySource(
|
|
scm_project=project,
|
|
source_path='inventory_file',
|
|
inventory=inventory)
|
|
with mock.patch.object(inv_src.scm_project, 'update') as mck_update:
|
|
inv_src.save()
|
|
mck_update.assert_called_once_with()
|
|
|
|
def test_source_location(self, scm_inventory_source):
|
|
# Combines project directory with the inventory file specified
|
|
inventory_update = InventoryUpdate(
|
|
inventory_source=scm_inventory_source,
|
|
source_path=scm_inventory_source.source_path)
|
|
assert inventory_update.get_actual_source_path().endswith('_92__test_proj/inventory_file')
|
|
|
|
def test_no_unwanted_updates(self, scm_inventory_source):
|
|
# Changing the non-sensitive fields should not trigger update
|
|
with mock.patch.object(scm_inventory_source.scm_project, 'update') as mck_update:
|
|
scm_inventory_source.name = 'edited_inventory'
|
|
scm_inventory_source.description = "I'm testing this!"
|
|
scm_inventory_source.save()
|
|
assert not mck_update.called
|