def test_serialise_options_dict_correctly(self):
        options_column_model = OptionsColumnModel('EventSlices=1-6,5-9,4:5:89 , WavelengthMax=78 , WavelengthMin=9')
        options_column_model.set_option('MergeScale', 1.5)

        options_string = options_column_model.get_options_string()

        self.assertEqual(options_string, 'EventSlices=1-6,5-9,4:5:89, MergeScale=1.5,'
                                         ' WavelengthMax=78.0, WavelengthMin=9.0')
Beispiel #2
0
    def test_serialise_options_dict_correctly(self):
        options_column_model = OptionsColumnModel('EventSlices=1-6,5-9,4:5:89 , WavelengthMax=78 , WavelengthMin=9')
        options_column_model.set_option('MergeScale', 1.5)

        options_string = options_column_model.get_options_string()

        self.assertEqual(options_string, 'EventSlices=1-6,5-9,4:5:89, MergeScale=1.5,'
                                         ' WavelengthMax=78.0, WavelengthMin=9.0')
Beispiel #3
0
 def test_that_non_bool_option_raises_error_if_option_is_bool(self):
     try:
         options_column_model = OptionsColumnModel('UseMirror=SomeString')
     except ValueError as e:
         self.assertEqual(str(e), 'Could not evaluate SomeString as a boolean value. It should be True or False.')
     else:
         self.assertTrue(False, 'A RuntimeError should be raised.')
Beispiel #4
0
    def test_that_parse_string_returns_correctly(self):
        string_to_parse = 'EventSlices=1-6,5-9,4:5:89 , WavelengthMax=78 , WavelengthMin=9'
        expected_dict = {'EventSlices': '1-6,5-9,4:5:89', 'WavelengthMax': '78', 'WavelengthMin': '9'}

        parsed_dict = OptionsColumnModel._parse_string(string_to_parse)

        self.assertEqual(parsed_dict, expected_dict)
Beispiel #5
0
    def test_that_OptionsColumnModel_get_hint_strategy(self):
        hint_strategy = OptionsColumnModel.get_hint_strategy()
        expected_hint_strategy = BasicHintStrategy({
            "WavelengthMin":
            'The min value of the wavelength when converting from TOF.',
            "WavelengthMax":
            'The max value of the wavelength when converting from TOF.',
            "PhiMin":
            'The min angle of the detector to accept.'
            ' Anti-clockwise from horizontal.',
            "PhiMax":
            'The max angle of the detector to accept.'
            ' Anti-clockwise from horizontal.',
            "UseMirror":
            'True or False. Whether or not to accept phi angle'
            ' in opposing quadrant',
            "MergeScale":
            'The scale applied to the HAB when merging',
            "MergeShift":
            'The shift applied to the HAB when merging',
            "EventSlices":
            'The event slices to reduce.'
            ' The format is the same as for the event slices'
            ' box in settings, however if a comma separated list is given '
            'it must be enclosed in quotes'
        })

        self.assertEqual(expected_hint_strategy, hint_strategy)
    def test_that_parse_string_returns_correctly(self):
        string_to_parse = 'EventSlices=1-6,5-9,4:5:89 , WavelengthMax=78 , WavelengthMin=9'
        expected_dict = {'EventSlices':'1-6,5-9,4:5:89', 'WavelengthMax':'78', 'WavelengthMin':'9'}

        parsed_dict = OptionsColumnModel._parse_string(string_to_parse)

        self.assertEqual(parsed_dict, expected_dict)
Beispiel #7
0
    def test_that_OptionsColumnModel_get_permissable_properties_returns_correct_properties(
            self):
        permissable_properties = OptionsColumnModel._get_permissible_properties(
        )

        self.assertEqual(permissable_properties, {
            "WavelengthMin": float,
            "WavelengthMax": float,
            "EventSlices": str
        })
    def test_that_OptionsColumnModel_get_hint_strategy(self):
        hint_strategy = OptionsColumnModel.get_hint_strategy()
        expected_hint_strategy = BasicHintStrategy({"WavelengthMin": 'The min value of the wavelength when converting from TOF.',
                                  "WavelengthMax": 'The max value of the wavelength when converting from TOF.',
                                  "MergeScale": 'The scale applied to the HAB when mergeing',
                                  "MergeShift": 'The shift applied to the HAB when mergeing',
                                  "EventSlices": 'The event slices to reduce.'
                                  ' The format is the same as for the event slices'
                                  ' box in settings, however if a comma separated list is given '
                                  'it must be enclosed in quotes'})

        self.assertEqual(expected_hint_strategy, hint_strategy)
Beispiel #9
0
    def test_that_OptionsColumnModel_get_hint_strategy(self):
        hint_strategy = OptionsColumnModel.get_hint_strategy()
        expected_hint_strategy = BasicHintStrategy({
            "WavelengthMin":
            'The min value of the wavelength when converting from TOF.',
            "WavelengthMax":
            'The max value of the wavelength when converting from TOF.',
            "EventSlices":
            'The event slices to reduce.'
            ' The format is the same as for the event slices'
            ' box in settings, however if a comma separated list is given '
            'it must be enclosed in quotes'
        })

        self.assertEqual(expected_hint_strategy, hint_strategy)
Beispiel #10
0
    def test_that_OptionsColumnModel_get_permissable_properties_returns_correct_properties(
            self):
        permissable_properties = OptionsColumnModel._get_permissible_properties(
        )

        self.assertEqual(
            permissable_properties, {
                "WavelengthMin": float,
                "WavelengthMax": float,
                "EventSlices": str,
                "MergeScale": float,
                "MergeShift": float,
                "PhiMin": float,
                "PhiMax": float,
                "UseMirror": options_column_bool
            })
Beispiel #11
0
    def test_that_falsy_options_are_evaluated_False(self):
        options_column_model = OptionsColumnModel('UseMirror=False')
        self.assertEqual(options_column_model.get_options(), {'UseMirror': False})

        options_column_model = OptionsColumnModel('UseMirror=0')
        self.assertEqual(options_column_model.get_options(), {'UseMirror': False})

        options_column_model = OptionsColumnModel('UseMirror=No')
        self.assertEqual(options_column_model.get_options(), {'UseMirror': False})

        options_column_model = OptionsColumnModel('UseMirror=F')
        self.assertEqual(options_column_model.get_options(), {'UseMirror': False})

        options_column_model = OptionsColumnModel('UseMirror=N')
        self.assertEqual(options_column_model.get_options(), {'UseMirror': False})

        options_column_model = OptionsColumnModel('UseMirror=fAlSE')
        self.assertEqual(options_column_model.get_options(), {'UseMirror': False})
Beispiel #12
0
    def test_that_truthy_options_are_evaluated_True(self):
        options_column_model = OptionsColumnModel('UseMirror=True')
        self.assertEqual(options_column_model.get_options(), {'UseMirror': True})

        options_column_model = OptionsColumnModel('UseMirror=1')
        self.assertEqual(options_column_model.get_options(), {'UseMirror': True})

        options_column_model = OptionsColumnModel('UseMirror=Yes')
        self.assertEqual(options_column_model.get_options(), {'UseMirror': True})

        options_column_model = OptionsColumnModel('UseMirror=T')
        self.assertEqual(options_column_model.get_options(), {'UseMirror': True})

        options_column_model = OptionsColumnModel('UseMirror=Y')
        self.assertEqual(options_column_model.get_options(), {'UseMirror': True})

        options_column_model = OptionsColumnModel('UseMirror=tRuE')
        self.assertEqual(options_column_model.get_options(), {'UseMirror': True})
Beispiel #13
0
 def test_that_non_bool_option_raises_error_if_option_is_bool(self):
     with self.assertRaises(ValueError):
         OptionsColumnModel("UseMirror=SomeString")
    def test_that_OptionsColumnModel_get_permissable_properties_returns_correct_properties(self):
        permissable_properties = OptionsColumnModel._get_permissible_properties()

        self.assertEqual(permissable_properties, {"WavelengthMin":float, "WavelengthMax": float, "EventSlices": str,
                                                  "MergeScale": float, "MergeShift": float})