mirror of
https://github.com/ansible/awx.git
synced 2026-03-01 00:38:45 -03:30
Fix bug with awx collection manual type alias (#13671)
* Fix bug with manual type alias * Add unit test for creating manual project with path
This commit is contained in:
@@ -284,13 +284,15 @@ def main():
|
|||||||
argument_spec=argument_spec,
|
argument_spec=argument_spec,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Alias for manual projects
|
||||||
|
if module.params.get('scm_type') == "manual":
|
||||||
|
module.params['scm_type'] = ''
|
||||||
|
|
||||||
# Extract our parameters
|
# Extract our parameters
|
||||||
name = module.params.get('name')
|
name = module.params.get('name')
|
||||||
new_name = module.params.get("new_name")
|
new_name = module.params.get("new_name")
|
||||||
copy_from = module.params.get('copy_from')
|
copy_from = module.params.get('copy_from')
|
||||||
scm_type = module.params.get('scm_type')
|
scm_type = module.params.get('scm_type')
|
||||||
if scm_type == "manual":
|
|
||||||
scm_type = ""
|
|
||||||
local_path = module.params.get('local_path')
|
local_path = module.params.get('local_path')
|
||||||
credential = module.params.get('credential')
|
credential = module.params.get('credential')
|
||||||
scm_update_on_launch = module.params.get('scm_update_on_launch')
|
scm_update_on_launch = module.params.get('scm_update_on_launch')
|
||||||
@@ -387,7 +389,8 @@ def main():
|
|||||||
# this is resolved earlier, so save an API call and don't do it again in the loop above
|
# this is resolved earlier, so save an API call and don't do it again in the loop above
|
||||||
project_fields['organization'] = org_id
|
project_fields['organization'] = org_id
|
||||||
|
|
||||||
if scm_type == '' and local_path is not None:
|
# Respect local_path if scm_type is manual type or not specified
|
||||||
|
if scm_type in ('', None) and local_path is not None:
|
||||||
project_fields['local_path'] = local_path
|
project_fields['local_path'] = local_path
|
||||||
|
|
||||||
if scm_update_cache_timeout not in (0, None) and scm_update_on_launch is not True:
|
if scm_update_cache_timeout not in (0, None) and scm_update_on_launch is not True:
|
||||||
|
|||||||
@@ -26,6 +26,24 @@ def test_create_project(run_module, admin_user, organization, silence_warning):
|
|||||||
assert result == {'name': 'foo', 'id': proj.id}
|
assert result == {'name': 'foo', 'id': proj.id}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_create_manual_project(run_module, admin_user, organization, mocker):
|
||||||
|
mocker.patch('awx.main.models.projects.Project.get_local_path_choices', return_value=['foo_folder/'])
|
||||||
|
result = run_module(
|
||||||
|
'project',
|
||||||
|
dict(name='foo', organization=organization.name, scm_type='manual', local_path='foo_folder/', wait=False),
|
||||||
|
admin_user,
|
||||||
|
)
|
||||||
|
assert result.pop('changed', None), result
|
||||||
|
|
||||||
|
proj = Project.objects.get(name='foo')
|
||||||
|
assert proj.local_path == 'foo_folder/'
|
||||||
|
assert proj.organization == organization
|
||||||
|
|
||||||
|
result.pop('invocation')
|
||||||
|
assert result == {'name': 'foo', 'id': proj.id}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.django_db
|
@pytest.mark.django_db
|
||||||
def test_create_project_copy_from(run_module, admin_user, organization, silence_warning):
|
def test_create_project_copy_from(run_module, admin_user, organization, silence_warning):
|
||||||
'''Test the copy_from functionality'''
|
'''Test the copy_from functionality'''
|
||||||
|
|||||||
Reference in New Issue
Block a user