summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-03-29 19:46:31 +0000
committerGerrit Code Review <review@openstack.org>2017-03-29 19:46:31 +0000
commit6e8ec4e7b0dada3791a6ccf1e54b2e9c9259f74c (patch)
treeff6452f5a106e028bbbef9c9950481625d54edfd
parent59e897ff0c03b735c7e86e5c12aa8b2daa56174b (diff)
parent378490d44da1e3b2fede1d868b5554d91f8c523d (diff)
downloadpython-saharaclient-6e8ec4e7b0dada3791a6ccf1e54b2e9c9259f74c.tar.gz
Merge "Fix a bug in jobs.py"
-rw-r--r--saharaclient/osc/v1/jobs.py15
-rw-r--r--saharaclient/tests/unit/osc/v1/test_jobs.py43
2 files changed, 53 insertions, 5 deletions
diff --git a/saharaclient/osc/v1/jobs.py b/saharaclient/osc/v1/jobs.py
index 4c50e52..d52ce70 100644
--- a/saharaclient/osc/v1/jobs.py
+++ b/saharaclient/osc/v1/jobs.py
@@ -174,11 +174,16 @@ class ExecuteJob(command.ShowOne):
client.jobs, parsed_args.job_template)
cluster_id = utils.get_resource_id(
client.clusters, parsed_args.cluster)
-
- input_id = utils.get_resource_id(
- client.data_sources, parsed_args.input)
- output_id = utils.get_resource_id(
- client.data_sources, parsed_args.output)
+ if parsed_args.input not in [None, "", "None"]:
+ input_id = utils.get_resource_id(
+ client.data_sources, parsed_args.input)
+ else:
+ input_id = None
+ if parsed_args.output not in [None, "", "None"]:
+ output_id = utils.get_resource_id(
+ client.data_sources, parsed_args.output)
+ else:
+ output_id = None
data = client.job_executions.create(
job_id=jt_id, cluster_id=cluster_id, input_id=input_id,
diff --git a/saharaclient/tests/unit/osc/v1/test_jobs.py b/saharaclient/tests/unit/osc/v1/test_jobs.py
index edbead9..6beaa15 100644
--- a/saharaclient/tests/unit/osc/v1/test_jobs.py
+++ b/saharaclient/tests/unit/osc/v1/test_jobs.py
@@ -89,10 +89,53 @@ class TestExecuteJob(TestJobs):
# Check that correct arguments were passed
self.je_mock.create.assert_called_once_with(
+ cluster_id='cluster_id', configs={}, input_id=None,
+ interface=None, is_protected=False, is_public=False,
+ job_id='job_id', output_id=None)
+
+ def test_job_execute_with_input_output_option(self):
+ arglist = ['--job-template', 'job-template', '--cluster', 'cluster',
+ '--input', 'input', '--output', 'output']
+ verifylist = [('job_template', 'job-template'), ('cluster', 'cluster'),
+ ('input', 'input'), ('output', 'output')]
+
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ self.cmd.take_action(parsed_args)
+
+ self.je_mock.create.assert_called_once_with(
cluster_id='cluster_id', configs={}, input_id='ds_id',
interface=None, is_protected=False, is_public=False,
job_id='job_id', output_id='ds_id')
+ # without option --output
+ arglist = ['--job-template', 'job-template', '--cluster', 'cluster',
+ '--input', 'input']
+ verifylist = [('job_template', 'job-template'), ('cluster', 'cluster'),
+ ('input', 'input')]
+
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ self.cmd.take_action(parsed_args)
+
+ self.je_mock.create.assert_called_with(
+ cluster_id='cluster_id', configs={}, input_id='ds_id',
+ interface=None, is_protected=False, is_public=False,
+ job_id='job_id', output_id=None)
+
+ # without options --output and --input
+ arglist = ['--job-template', 'job-template', '--cluster', 'cluster']
+ verifylist = [('job_template', 'job-template'), ('cluster', 'cluster')]
+
+ parsed_args = self.check_parser(self.cmd, arglist, verifylist)
+
+ self.cmd.take_action(parsed_args)
+
+ self.je_mock.create.assert_called_with(
+ cluster_id='cluster_id', configs={}, input_id=None,
+ interface=None, is_protected=False, is_public=False,
+ job_id='job_id', output_id=None)
+
def test_job_execute_all_options(self):
arglist = ['--job-template', 'job-template', '--cluster', 'cluster',
'--input', 'input', '--output', 'output', '--params',