def test_that_general_isis_default_values_are_set_up(self): state = StateMove() state.detectors = { DetectorType.LAB.value: StateMoveDetectors(), DetectorType.HAB.value: StateMoveDetectors() } self.assertEqual(state.sample_offset, 0.0) self.assertEqual(state.sample_offset_direction, CanonicalCoordinates.Z) self.assertEqual( state.detectors[DetectorType.HAB.value].x_translation_correction, 0.0) self.assertEqual( state.detectors[DetectorType.HAB.value].y_translation_correction, 0.0) self.assertEqual( state.detectors[DetectorType.HAB.value].z_translation_correction, 0.0) self.assertEqual( state.detectors[DetectorType.HAB.value].rotation_correction, 0.0) self.assertEqual( state.detectors[DetectorType.HAB.value].side_correction, 0.0) self.assertEqual( state.detectors[DetectorType.HAB.value].radius_correction, 0.0) self.assertEqual( state.detectors[DetectorType.HAB.value].x_tilt_correction, 0.0) self.assertEqual( state.detectors[DetectorType.HAB.value].y_tilt_correction, 0.0) self.assertEqual( state.detectors[DetectorType.HAB.value].z_tilt_correction, 0.0) self.assertEqual( state.detectors[DetectorType.HAB.value].sample_centre_pos1, 0.0) self.assertEqual( state.detectors[DetectorType.HAB.value].sample_centre_pos2, 0.0)
def test_that_raises_if_the_short_detector_name_is_not_set_up(self): state = StateMove() state.detectors = {DetectorType.LAB.value: StateMoveDetectors(), DetectorType.HAB.value: StateMoveDetectors()} state.detectors[DetectorType.HAB.value].detector_name = "test" state.detectors[DetectorType.LAB.value].detector_name = "test" state.detectors[DetectorType.HAB.value].detector_name_short = "test" with self.assertRaises(ValueError): state.validate() state.detectors[DetectorType.LAB.value].detector_name_short = "test" self.assertIsNone(state.validate())
def test_that_user_file_items_interpreted_correctly(self): state = AllStates() state.move.sample_offset = 1.78 / 1000. state.scale.width = 1.2 state.scale.height = 1.6 state.scale.thickness = 1.8 state.scale.shape = SampleShape.FLAT_PLATE state.convert_to_q.radius_cutoff = 45. / 1000. state.convert_to_q.q_resolution_a1 = 1.5 / 1000. state.convert_to_q.q_resolution_a2 = 2.5 / 1000. state.convert_to_q.q_resolution_h1 = 1.5 / 1000. state.convert_to_q.q_resolution_h2 = 2.5 / 1000. state.convert_to_q.q_resolution_delta_r = 0.1 / 1000. state.mask.radius_min = 12. / 1000. state.mask.radius_max = 13. / 1000. state.move.detectors = { DetectorType.LAB.value: StateMoveDetectors(), DetectorType.HAB.value: StateMoveDetectors() } state.move.detectors[ DetectorType.LAB.value].sample_centre_pos1 = 21.5 / 1000. state.move.detectors[ DetectorType.LAB.value].sample_centre_pos2 = 17.8 / 1000. state.move.detectors[ DetectorType.HAB.value].sample_centre_pos1 = 25.1 / 1000. state.move.detectors[ DetectorType.HAB.value].sample_centre_pos2 = 16.9 / 1000. state_gui_model = StateGuiModel(state) self.assertEqual(state_gui_model.sample_width, 1.2) self.assertEqual(state_gui_model.sample_height, 1.6) self.assertEqual(state_gui_model.sample_thickness, 1.8) self.assertEqual(state_gui_model.z_offset, 1.78) self.assertEqual(state_gui_model.sample_shape, SampleShape.FLAT_PLATE) self.assertEqual(state_gui_model.r_cut, 45.) self.assertEqual(state_gui_model.q_resolution_source_a, 1.5) self.assertEqual(state_gui_model.q_resolution_sample_a, 2.5) self.assertEqual(state_gui_model.q_resolution_source_h, 1.5) self.assertEqual(state_gui_model.q_resolution_sample_h, 2.5) self.assertEqual(state_gui_model.q_resolution_delta_r, 0.1) self.assertEqual(state_gui_model.radius_limit_min, 12.) self.assertEqual(state_gui_model.radius_limit_max, 13.) self.assertEqual(state_gui_model.lab_pos_1, 21.5) self.assertEqual(state_gui_model.lab_pos_2, 17.8) self.assertEqual(state_gui_model.hab_pos_1, 25.1) self.assertEqual(state_gui_model.hab_pos_2, 16.9)