Exemple #1
0
    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."
        )
Exemple #2
0
def getReductionRun(with_variables=True):
    instrument = InstrumentUtils().get_instrument("valid")
    experiment = Experiment(reference_number=1)
    experiment.save()
    reduction_run = ReductionRun(
        instrument=instrument,
        run_number=1,
        experiment=experiment,
        run_version=0,
        status=StatusUtils().get_queued(),
        script=getValidScript("reduce.py"),
    )
    reduction_run.save()

    if with_variables:
        variable = RunVariable(
            reduction_run=reduction_run, name="test", value="testvalue1", type="text", is_advanced=False
        )
        variable.save()
        reduction_run.run_variables.add(variable)

        variable = RunVariable(
            reduction_run=reduction_run, name="advanced_test", value="testvalue2", type="text", is_advanced=True
        )
        variable.save()
        reduction_run.run_variables.add(variable)

        reduction_run.save()

    return reduction_run
Exemple #3
0
def getReductionRun(with_variables=True):
    instrument = InstrumentUtils().get_instrument('valid')
    experiment = Experiment(reference_number=1)
    experiment.save()
    reduction_run = ReductionRun(instrument=instrument, run_number=1, experiment=experiment, run_version=0, status=StatusUtils().get_queued(), script=getValidScript('reduce.py'))
    reduction_run.save()        

    if with_variables:            
        variable = RunVariable(reduction_run=reduction_run,name='test',value='testvalue1',type='text',is_advanced=False)
        variable.save()
        reduction_run.run_variables.add(variable)

        variable = RunVariable(reduction_run=reduction_run,name='advanced_test',value='testvalue2',type='text',is_advanced=True)
        variable.save()
        reduction_run.run_variables.add(variable)

        reduction_run.save()

    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.")