mirror of
https://github.com/ansible/awx.git
synced 2026-01-10 15:32:07 -03:30
Fix copy_from warning message
- warn() does not take keyword 'msg' - add testing around the copy_from parameter for project creation
This commit is contained in:
parent
2afa406b7f
commit
5da02690c1
@ -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
|
||||
|
||||
@ -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.")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user