def test_get_script_and_arguments_successful(self): run_variables = [] reduction_run = getReductionRun() reduction_run.script = getValidScript("reduce.py") variable = RunVariable( reduction_run=reduction_run, name="test", value="testvalue1", type="text", is_advanced=False ) variable.save() run_variables.append(variable) variable = RunVariable( reduction_run=reduction_run, name="advanced_test", value="testvalue2", type="text", is_advanced=True ) variable.save() run_variables.append(variable) script, arguments = ReductionRunUtils().get_script_and_arguments(reduction_run) self.assertNotEqual(script, None, "Expecting to get a script path back.") self.assertNotEqual(script, "", "Expecting to get a script path back.") self.assertNotEqual(arguments, None, "Expecting to get some arguments path back.") self.assertNotEqual(arguments, {}, "Expecting to get some arguments path back.") self.assertTrue("standard_vars" in arguments, "Expecting arguments to have a 'standard_vars' key.") self.assertTrue("advanced_vars" in arguments, "Expecting arguments to have a 'advanced_vars' key.") self.assertEqual( arguments["standard_vars"]["test"], "testvalue1", "Expecting to find testvalue1 in standard_vars." ) self.assertEqual( arguments["advanced_vars"]["advanced_test"], "testvalue2", "Expecting to find testvalue2 in advanced_vars." )
def createReductionRun(self): instrument = InstrumentUtils().get_instrument("valid") instrument.save() experiment = Experiment(reference_number=1) experiment.save() reduction_run = ReductionRun(run_number=self.run_number, instrument=instrument, experiment=experiment, run_version=1, status=StatusUtils().get_queued(), script=getValidScript('reduce.py')) self.run_number += 1 reduction_run.save() variables = InstrumentVariablesUtils().get_variables_for_run( reduction_run) VariableUtils().save_run_variables(variables, reduction_run) return reduction_run
def createReductionRun(self): instrument = InstrumentUtils().get_instrument("valid") instrument.save() experiment = Experiment(reference_number=1) experiment.save() reduction_run = ReductionRun( run_number=self.run_number, instrument=instrument, experiment=experiment, run_version=1, status=StatusUtils().get_queued(), script=getValidScript("reduce.py"), ) self.run_number += 1 reduction_run.save() variables = InstrumentVariablesUtils().get_variables_for_run(reduction_run) VariableUtils().save_run_variables(variables, reduction_run) return reduction_run
def test_get_script_and_arguments_successful(self): run_variables = [] reduction_run = getReductionRun() reduction_run.script = getValidScript("reduce.py") variable = RunVariable(reduction_run=reduction_run, name='test', value='testvalue1', type='text', is_advanced=False) variable.save() run_variables.append(variable) variable = RunVariable(reduction_run=reduction_run, name='advanced_test', value='testvalue2', type='text', is_advanced=True) variable.save() run_variables.append(variable) script, arguments = ReductionRunUtils().get_script_and_arguments( reduction_run) self.assertNotEqual(script, None, "Expecting to get a script path back.") self.assertNotEqual(script, "", "Expecting to get a script path back.") self.assertNotEqual(arguments, None, "Expecting to get some arguments path back.") self.assertNotEqual(arguments, {}, "Expecting to get some arguments path back.") self.assertTrue('standard_vars' in arguments, "Expecting arguments to have a 'standard_vars' key.") self.assertTrue('advanced_vars' in arguments, "Expecting arguments to have a 'advanced_vars' key.") self.assertEqual(arguments['standard_vars']['test'], 'testvalue1', "Expecting to find testvalue1 in standard_vars.") self.assertEqual(arguments['advanced_vars']['advanced_test'], 'testvalue2', "Expecting to find testvalue2 in advanced_vars.")