From 48f10669d679070628500773984357f151df1f4c Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Tue, 26 Nov 2019 09:39:05 -0500 Subject: [PATCH 1/2] fix duplicate exception sanity error --- awx_collection/plugins/modules/tower_credential.py | 2 +- awx_collection/plugins/modules/tower_group.py | 2 +- awx_collection/plugins/modules/tower_label.py | 2 +- awx_collection/plugins/modules/tower_team.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/awx_collection/plugins/modules/tower_credential.py b/awx_collection/plugins/modules/tower_credential.py index 6d21f5a00d..91643f65d4 100644 --- a/awx_collection/plugins/modules/tower_credential.py +++ b/awx_collection/plugins/modules/tower_credential.py @@ -404,7 +404,7 @@ def main(): result = credential.delete(**params) except (exc.NotFound) as excinfo: module.fail_json(msg='Failed to update credential, organization not found: {0}'.format(excinfo), changed=False) - except (exc.ConnectionError, exc.BadRequest, exc.NotFound, exc.AuthError) as excinfo: + except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo: module.fail_json(msg='Failed to update credential: {0}'.format(excinfo), changed=False) json_output['changed'] = result['changed'] diff --git a/awx_collection/plugins/modules/tower_group.py b/awx_collection/plugins/modules/tower_group.py index a30500d09d..8b9677da79 100644 --- a/awx_collection/plugins/modules/tower_group.py +++ b/awx_collection/plugins/modules/tower_group.py @@ -179,7 +179,7 @@ def main(): result = group.delete(**params) except (exc.NotFound) as excinfo: module.fail_json(msg='Failed to update the group, inventory not found: {0}'.format(excinfo), changed=False) - except (exc.ConnectionError, exc.BadRequest, exc.NotFound, exc.AuthError) as excinfo: + except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo: module.fail_json(msg='Failed to update the group: {0}'.format(excinfo), changed=False) json_output['changed'] = result['changed'] diff --git a/awx_collection/plugins/modules/tower_label.py b/awx_collection/plugins/modules/tower_label.py index 254d9d4986..e5085cfd27 100644 --- a/awx_collection/plugins/modules/tower_label.py +++ b/awx_collection/plugins/modules/tower_label.py @@ -94,7 +94,7 @@ def main(): result = label.delete(name=name, organization=org['id']) except (exc.NotFound) as excinfo: module.fail_json(msg='Failed to update label, organization not found: {0}'.format(excinfo), changed=False) - except (exc.ConnectionError, exc.BadRequest, exc.NotFound, exc.AuthError) as excinfo: + except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo: module.fail_json(msg='Failed to update label: {0}'.format(excinfo), changed=False) json_output['changed'] = result['changed'] diff --git a/awx_collection/plugins/modules/tower_team.py b/awx_collection/plugins/modules/tower_team.py index 80aff36f04..dc34f4d706 100644 --- a/awx_collection/plugins/modules/tower_team.py +++ b/awx_collection/plugins/modules/tower_team.py @@ -103,7 +103,7 @@ def main(): result = team.delete(name=name, organization=org['id']) except (exc.NotFound) as excinfo: module.fail_json(msg='Failed to update team, organization not found: {0}'.format(excinfo), changed=False) - except (exc.ConnectionError, exc.BadRequest, exc.NotFound, exc.AuthError) as excinfo: + except (exc.ConnectionError, exc.BadRequest, exc.AuthError) as excinfo: module.fail_json(msg='Failed to update team: {0}'.format(excinfo), changed=False) json_output['changed'] = result['changed'] From 081a0fc04e0ddf116f191a7355eb32b5f38a1712 Mon Sep 17 00:00:00 2001 From: AlanCoding Date: Tue, 26 Nov 2019 09:45:54 -0500 Subject: [PATCH 2/2] fix other assorted sanity failures --- awx_collection/test/awx/conftest.py | 5 +++-- awx_collection/test/awx/test_group.py | 3 +++ awx_collection/test/awx/test_inventory_source.py | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/awx_collection/test/awx/conftest.py b/awx_collection/test/awx/conftest.py index 09ff9e78f1..cce48746fb 100644 --- a/awx_collection/test/awx/conftest.py +++ b/awx_collection/test/awx/conftest.py @@ -71,10 +71,11 @@ def run_module(request): resp.status_code = django_response.status_code if request.config.getoption('verbose') > 0: - logger.info('{} {} by {}, code:{}'.format( + logger.info( + '%s %s by %s, code:%s', method, '/api/' + url.split('/api/')[1], request_user.username, resp.status_code - )) + ) return resp diff --git a/awx_collection/test/awx/test_group.py b/awx_collection/test/awx/test_group.py index c5cb12c8d7..59cb68e5f8 100644 --- a/awx_collection/test/awx/test_group.py +++ b/awx_collection/test/awx/test_group.py @@ -1,3 +1,6 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import pytest from awx.main.models import Organization, Inventory, Group diff --git a/awx_collection/test/awx/test_inventory_source.py b/awx_collection/test/awx/test_inventory_source.py index 882156a42f..0b04126a0c 100644 --- a/awx_collection/test/awx/test_inventory_source.py +++ b/awx_collection/test/awx/test_inventory_source.py @@ -1,3 +1,6 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + import pytest from awx.main.models import Organization, Inventory, InventorySource, Project