mirror of
https://github.com/ansible/awx.git
synced 2026-02-16 10:40:01 -03:30
Allow manual updates in spite of update_on_project_update
This makes inventory sources with the that flag set behave like any other inventory source with manual use. They will still update when triggered by a project SCM hash change.
This commit is contained in:
@@ -5,7 +5,7 @@ from django.core.exceptions import ValidationError
|
||||
|
||||
from awx.api.versioning import reverse
|
||||
|
||||
from awx.main.models import InventorySource, Project, ProjectUpdate
|
||||
from awx.main.models import InventorySource
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -248,31 +248,6 @@ def test_inventory_update_access_called(post, inventory_source, alice, mock_acce
|
||||
mock_instance.can_start.assert_called_once_with(inventory_source)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
class TestUpdateOnProjUpdate:
|
||||
|
||||
def test_no_access_update_denied(self, admin_user, scm_inventory, mock_access, post):
|
||||
inv_src = scm_inventory.inventory_sources.first()
|
||||
with mock_access(Project) as mock_access:
|
||||
mock_access.can_start = mock.MagicMock(return_value=False)
|
||||
r = post(reverse('api:inventory_source_update_view', kwargs={'pk': inv_src.id}),
|
||||
{}, admin_user, expect=403)
|
||||
assert 'You do not have permission to update project' in r.data['detail']
|
||||
|
||||
def test_no_access_update_allowed(self, admin_user, scm_inventory, mock_access, post):
|
||||
inv_src = scm_inventory.inventory_sources.first()
|
||||
inv_src.source_project.scm_type = 'git'
|
||||
inv_src.source_project.save()
|
||||
with mock.patch('awx.api.views.InventorySourceUpdateView.get_object') as get_object:
|
||||
get_object.return_value = inv_src
|
||||
with mock.patch.object(inv_src.source_project, 'update') as mock_update:
|
||||
mock_update.return_value = ProjectUpdate(pk=48, id=48)
|
||||
r = post(reverse('api:inventory_source_update_view', kwargs={'pk': inv_src.id}),
|
||||
{}, admin_user, expect=202)
|
||||
assert 'dependent project' in r.data['detail']
|
||||
assert not r.data['inventory_update']
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_inventory_source_vars_prohibition(post, inventory, admin_user):
|
||||
with mock.patch('awx.api.serializers.settings') as mock_settings:
|
||||
|
||||
Reference in New Issue
Block a user