diff --git a/setup.py b/setup.py index 295990b..5932f46 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ name="ctm-python-client", packages=find_packages(where="src"), package_dir={"": "src"}, - version="2.4.1", + version="2.4.2", description="Python Workflows for Control-M", long_description=long_description, long_description_content_type='text/markdown', diff --git a/src/aapi/bases.py b/src/aapi/bases.py index 32c613f..3fed094 100644 --- a/src/aapi/bases.py +++ b/src/aapi/bases.py @@ -85,7 +85,7 @@ def run_on_demand(self, environment: Environment, inpath: str = f'run_on_demand{ else: on_demand_workflow.add(self, inpath=inpath) - on_demand_workflow.run_on_demand( + return on_demand_workflow.run_on_demand( skip_login=skip_login, file_path=file_path, delete_afterwards=delete_afterwards, diff --git a/src/ctm_python_client/__init__.py b/src/ctm_python_client/__init__.py index cd2e500..62b11c2 100644 --- a/src/ctm_python_client/__init__.py +++ b/src/ctm_python_client/__init__.py @@ -1,2 +1,2 @@ -__version__ = '2.4.1' +__version__ = '2.4.2' __author__ = 'BMC Software' \ No newline at end of file diff --git a/src/ctm_python_client/core/workflow.py b/src/ctm_python_client/core/workflow.py index 065e4d1..0f38613 100644 --- a/src/ctm_python_client/core/workflow.py +++ b/src/ctm_python_client/core/workflow.py @@ -438,9 +438,12 @@ def run_on_demand(self, skip_login: bool = False, file_path: str = None, delete_ run_.open_in_browser() return run_ except Exception as e: - errors = [err.get('message', '') + ' ' + err.get('item', '') - for err in json.loads(e.body)['errors']] - raise RuntimeError(f"AAPI request failed: {', '.join(errors)}") + if e.body: + errors = [err.get('message', '') + ' ' + err.get('item', '') + for err in json.loads(e.body)['errors']] + raise RuntimeError(f"AAPI request failed: {', '.join(errors)}") + else: + raise e finally: if delete_afterwards: fpath.unlink() diff --git a/tests/test_aapi.py b/tests/test_aapi.py index be36651..6ed1549 100644 --- a/tests/test_aapi.py +++ b/tests/test_aapi.py @@ -1,4 +1,4 @@ - +import pytest import json import aapi from ctm_python_client.core.workflow import Workflow, WorkflowDefaults, BaseWorkflow @@ -151,3 +151,12 @@ def test_job_in_folder_run_as(): ''') assert workflow.get("TestFolder").as_aapi_dict() == o +def test_run_ondemand_without_jobs(): + demand_sub_folder = aapi.SubFolder("TestFolder") + with pytest.raises(Exception, match='Run is not allowed for json without jobs'): + demand_sub_folder.run_on_demand(Environment.create_workbench("refael"), WorkflowDefaults(run_as='workbench'), run_as='workbench', controlm_server='workbench') + + demand_folder = aapi.Folder("TestFolder") + with pytest.raises(Exception, match='Run is not allowed for json without jobs'): + demand_folder.run_on_demand(Environment.create_workbench("refael"), WorkflowDefaults(run_as='workbench'), run_as='workbench', controlm_server='workbench') + diff --git a/tests/test_sanity.py b/tests/test_sanity.py index 68935d9..da5080e 100644 --- a/tests/test_sanity.py +++ b/tests/test_sanity.py @@ -2,6 +2,6 @@ def test_version_author(): import ctm_python_client assert ctm_python_client.__author__ == 'BMC Software' - assert ctm_python_client.__version__ == '2.4.1' + assert ctm_python_client.__version__ == '2.4.2'