more rename, mostly in test

This commit is contained in:
Seth Foster
2021-04-29 11:58:41 -04:00
parent a695274cb6
commit 7a63785255
105 changed files with 616 additions and 625 deletions

View File

@@ -49,12 +49,12 @@ def mock_awx_ping_response(self, method, url, **kwargs):
def test_version_warning(collection_import, silence_warning):
TowerAPIModule = collection_import('plugins.module_utils.tower_api').ControllerAPIModule
ControllerAPIModule = collection_import('plugins.module_utils.controller_api').ControllerAPIModule
cli_data = {'ANSIBLE_MODULE_ARGS': {}}
testargs = ['module_file2.py', json.dumps(cli_data)]
with mock.patch.object(sys, 'argv', testargs):
with mock.patch('ansible.module_utils.urls.Request.open', new=mock_awx_ping_response):
my_module = TowerAPIModule(argument_spec=dict())
my_module = ControllerAPIModule(argument_spec=dict())
my_module._COLLECTION_VERSION = "2.0.0"
my_module._COLLECTION_TYPE = "awx"
my_module.get_endpoint('ping')
@@ -64,13 +64,13 @@ def test_version_warning(collection_import, silence_warning):
def test_version_warning_strictness_awx(collection_import, silence_warning):
TowerAPIModule = collection_import('plugins.module_utils.tower_api').ControllerAPIModule
ControllerAPIModule = collection_import('plugins.module_utils.controller_api').ControllerAPIModule
cli_data = {'ANSIBLE_MODULE_ARGS': {}}
testargs = ['module_file2.py', json.dumps(cli_data)]
# Compare 1.0.0 to 1.2.3 (major matches)
with mock.patch.object(sys, 'argv', testargs):
with mock.patch('ansible.module_utils.urls.Request.open', new=mock_awx_ping_response):
my_module = TowerAPIModule(argument_spec=dict())
my_module = ControllerAPIModule(argument_spec=dict())
my_module._COLLECTION_VERSION = "1.0.0"
my_module._COLLECTION_TYPE = "awx"
my_module.get_endpoint('ping')
@@ -79,7 +79,7 @@ def test_version_warning_strictness_awx(collection_import, silence_warning):
# Compare 1.2.0 to 1.2.3 (major matches minor does not count)
with mock.patch.object(sys, 'argv', testargs):
with mock.patch('ansible.module_utils.urls.Request.open', new=mock_awx_ping_response):
my_module = TowerAPIModule(argument_spec=dict())
my_module = ControllerAPIModule(argument_spec=dict())
my_module._COLLECTION_VERSION = "1.2.0"
my_module._COLLECTION_TYPE = "awx"
my_module.get_endpoint('ping')
@@ -87,13 +87,13 @@ def test_version_warning_strictness_awx(collection_import, silence_warning):
def test_version_warning_strictness_tower(collection_import, silence_warning):
TowerAPIModule = collection_import('plugins.module_utils.tower_api').ControllerAPIModule
ControllerAPIModule = collection_import('plugins.module_utils.controller_api').ControllerAPIModule
cli_data = {'ANSIBLE_MODULE_ARGS': {}}
testargs = ['module_file2.py', json.dumps(cli_data)]
# Compare 1.2.0 to 1.2.3 (major/minor matches)
with mock.patch.object(sys, 'argv', testargs):
with mock.patch('ansible.module_utils.urls.Request.open', new=mock_tower_ping_response):
my_module = TowerAPIModule(argument_spec=dict())
my_module = ControllerAPIModule(argument_spec=dict())
my_module._COLLECTION_VERSION = "1.2.0"
my_module._COLLECTION_TYPE = "tower"
my_module.get_endpoint('ping')
@@ -102,7 +102,7 @@ def test_version_warning_strictness_tower(collection_import, silence_warning):
# Compare 1.0.0 to 1.2.3 (major/minor fail to match)
with mock.patch.object(sys, 'argv', testargs):
with mock.patch('ansible.module_utils.urls.Request.open', new=mock_tower_ping_response):
my_module = TowerAPIModule(argument_spec=dict())
my_module = ControllerAPIModule(argument_spec=dict())
my_module._COLLECTION_VERSION = "1.0.0"
my_module._COLLECTION_TYPE = "tower"
my_module.get_endpoint('ping')
@@ -112,12 +112,12 @@ def test_version_warning_strictness_tower(collection_import, silence_warning):
def test_type_warning(collection_import, silence_warning):
TowerAPIModule = collection_import('plugins.module_utils.tower_api').ControllerAPIModule
ControllerAPIModule = collection_import('plugins.module_utils.controller_api').ControllerAPIModule
cli_data = {'ANSIBLE_MODULE_ARGS': {}}
testargs = ['module_file2.py', json.dumps(cli_data)]
with mock.patch.object(sys, 'argv', testargs):
with mock.patch('ansible.module_utils.urls.Request.open', new=mock_awx_ping_response):
my_module = TowerAPIModule(argument_spec={})
my_module = ControllerAPIModule(argument_spec={})
my_module._COLLECTION_VERSION = ping_version
my_module._COLLECTION_TYPE = "tower"
my_module.get_endpoint('ping')
@@ -128,15 +128,15 @@ def test_type_warning(collection_import, silence_warning):
def test_duplicate_config(collection_import, silence_warning):
# imports done here because of PATH issues unique to this test suite
TowerAPIModule = collection_import('plugins.module_utils.tower_api').ControllerAPIModule
ControllerAPIModule = collection_import('plugins.module_utils.controller_api').ControllerAPIModule
data = {'name': 'zigzoom', 'zig': 'zoom', 'tower_username': 'bob', 'tower_config_file': 'my_config'}
with mock.patch.object(TowerAPIModule, 'load_config') as mock_load:
with mock.patch.object(ControllerAPIModule, 'load_config') as mock_load:
argument_spec = dict(
name=dict(required=True),
zig=dict(type='str'),
)
TowerAPIModule(argument_spec=argument_spec, direct_params=data)
ControllerAPIModule(argument_spec=argument_spec, direct_params=data)
assert mock_load.mock_calls[-1] == mock.call('my_config')
silence_warning.assert_called_once_with(
@@ -152,11 +152,11 @@ def test_no_templated_values(collection_import):
Those replacements should happen at build time, so they should not be
checked into source.
"""
TowerAPIModule = collection_import('plugins.module_utils.tower_api').ControllerAPIModule
assert TowerAPIModule._COLLECTION_VERSION == "0.0.1-devel", (
ControllerAPIModule = collection_import('plugins.module_utils.controller_api').ControllerAPIModule
assert ControllerAPIModule._COLLECTION_VERSION == "0.0.1-devel", (
'The collection version is templated when the collection is built ' 'and the code should retain the placeholder of "0.0.1-devel".'
)
InventoryModule = collection_import('plugins.inventory.tower').InventoryModule
InventoryModule = collection_import('plugins.inventory.controller').InventoryModule
assert InventoryModule.NAME == 'awx.awx.tower', (
'The inventory plugin FQCN is templated when the collection is built ' 'and the code should retain the default of awx.awx.'
)
@@ -172,7 +172,7 @@ def test_conflicting_name_and_id(run_module, admin_user):
org_by_id = Organization.objects.create(name='foo')
slug = str(org_by_id.id)
org_by_name = Organization.objects.create(name=slug)
result = run_module('tower_team', {'name': 'foo_team', 'description': 'fooin around', 'organization': slug}, admin_user)
result = run_module('team', {'name': 'foo_team', 'description': 'fooin around', 'organization': slug}, admin_user)
assert not result.get('failed', False), result.get('msg', result)
team = Team.objects.filter(name='foo_team').first()
assert str(team.organization_id) == slug, 'Lookup by id should be preferenced over name in cases of conflict.'
@@ -195,9 +195,7 @@ def test_multiple_lookup(run_module, admin_user):
scm_type='git',
scm_url="https://github.com/ansible/ansible-tower-samples",
)
result = run_module(
'tower_job_template', {'name': 'Demo Job Template', 'project': proj1.name, 'inventory': inv.id, 'playbook': 'hello_world.yml'}, admin_user
)
result = run_module('job_template', {'name': 'Demo Job Template', 'project': proj1.name, 'inventory': inv.id, 'playbook': 'hello_world.yml'}, admin_user)
assert result.get('failed', False)
assert 'projects' in result['msg']
assert 'foo' in result['msg']