def get_entity(client, namespace, entity): entity_path = utils.build_core_v2_path(namespace, 'entities', entity) resp = client.get(entity_path) if resp.status != 200: raise errors.SyncError( "Entity with name '{0}' does not exist on remote.".format(entity)) return resp.json
def get_check(client, namespace, check): check_path = utils.build_core_v2_path(namespace, 'checks', check) resp = client.get(check_path) if resp.status != 200: raise errors.SyncError( "Check with name '{0}' does not exist on remote.".format(check)) return resp.json
def test_missing_entity_on_remote(self, mocker): get_entity_mock = mocker.patch.object(event, 'get_entity') get_entity_mock.side_effect = errors.SyncError('Error') set_module_args( entity='awesome_entity', check='awesome_check', ) with pytest.raises(AnsibleFailJson, match='Error'): event.main()
def _abort(msg, *args, **kwargs): raise errors.SyncError(msg.format(*args, **kwargs))
def get(client, path): resp = client.get(path) if resp.status != 200: raise errors.SyncError("GET {0} failed with status {1}: {2}".format( path, resp.status, resp.data)) return resp.json