Merge pull request #10528 from fosterseth/fix_collection_copy_from_error

Fix awx collections copy_item warning keyword error

SUMMARY


warn() does not take keyword 'msg'
add testing around the copy_from parameter for project creation


ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME


API

AWX VERSION

awx: 19.2.1

Reviewed-by: Alan Rominger <arominge@redhat.com>
Reviewed-by: Bianca Henderson <beeankha@gmail.com>
This commit is contained in:
softwarefactory-project-zuul[bot] 2021-06-28 15:16:51 +00:00 committed by GitHub
commit 017bb63023
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View File

@ -421,7 +421,7 @@ class ControllerAPIModule(ControllerModule):
def copy_item(self, existing_item, copy_from_name_or_id, new_item_name, endpoint=None, item_type='unknown', copy_lookup_data=None):
if existing_item is not None:
self.warn(msg="A {0} with the name {1} already exists.".format(item_type, new_item_name))
self.warn("A {0} with the name {1} already exists.".format(item_type, new_item_name))
self.json_output['changed'] = False
self.json_output['copied'] = False
return existing_item

View File

@ -24,3 +24,26 @@ def test_create_project(run_module, admin_user, organization, silence_warning):
result.pop('invocation')
assert result == {'name': 'foo', 'id': proj.id}
@pytest.mark.django_db
def test_create_project_copy_from(run_module, admin_user, organization, silence_warning):
''' Test the copy_from functionality'''
result = run_module(
'project',
dict(name='foo', organization=organization.name, scm_type='git', scm_url='https://foo.invalid', wait=False, scm_update_cache_timeout=5),
admin_user,
)
assert result.pop('changed', None), result
proj_name = 'bar'
result = run_module(
'project',
dict(name=proj_name, copy_from='foo', scm_type='git', wait=False),
admin_user,
)
assert result.pop('changed', None), result
result = run_module(
'project',
dict(name=proj_name, copy_from='foo', scm_type='git', wait=False),
admin_user,
)
silence_warning.assert_called_with(f"A project with the name {proj_name} already exists.")