def test_get_points_should_load_points(self, *args):
        self.setup_mocks(args)
        expected_lower = {
                (1.0, 1.0): (1.0,  1.0), (0.0, 1.0): (-1.0,  1.0),
                (1.0, 0.0): (1.0, -1.0), (0.0, 0.0): (-1.0, -1.0)
                }
        expected_upper = {
                (1.0, 1.0): (1.0,  1.0), (0.0, 1.0): (-1.0,  1.0),
                (1.0, 0.0): (1.0, -1.0), (0.0, 0.0): (-1.0, -1.0)
                }
        expected_height = 1.1
        config = self.default_config
        config.calibration.height = expected_height
        config.calibration.lower_points = expected_lower
        config.calibration.upper_points = expected_upper

        self.mock_configuration_manager.load.return_value = config

        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        lower_points_result = calibration_api.get_lower_points()
        upper_points_result = calibration_api.get_upper_points()
        height_result = calibration_api.get_height()

        self.assertEquals(expected_height, height_result)
        self.assertEquals(expected_lower, lower_points_result)
        self.assertEquals(expected_upper, upper_points_result)
    def test_change_pattern_should_raise_exception_when_test_patterns_unavailable(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        with self.assertRaises(Exception):
            calibration_api.show_test_pattern("Shrubberies")
    def test_set_orientation_saves_orientation_settings(self, *args):
        self.setup_mocks(args)
        config = self.default_config
        expected_config = self.default_config
        expected_flip_x_axis = True
        expected_flip_y_axis = True
        expected_swap_axis = True

        config.calibration.flip_x_axis = False
        config.calibration.flip_y_axis = False
        config.calibration.swap_axis = False

        expected_config.calibration.flip_x_axis = True
        expected_config.calibration.flip_y_axis = True
        expected_config.calibration.swap_axis = True

        self.mock_configuration_manager.load.return_value = config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.set_orientation(expected_flip_x_axis,
                                        expected_flip_y_axis,
                                        expected_swap_axis)

        self.assertConfigurationEqual(
            expected_config,
            self.mock_configuration_manager.save.mock_calls[0][1][0])
    def test_set_print_area_saves_print_area_settings(self, *args):
        self.setup_mocks(args)
        config = self.default_config
        expected_config = self.default_config
        expected_print_area_x = 20.0
        expected_print_area_y = 20.0
        expected_print_area_z = 20.0

        config.calibration.print_area_x = 12.0
        config.calibration.print_area_y = 12.0
        config.calibration.print_area_z = 12.0

        expected_config.calibration.print_area_x = 20.0
        expected_config.calibration.print_area_y = 20.0
        expected_config.calibration.print_area_z = 20.0

        self.mock_configuration_manager.load.return_value = config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.set_print_area(expected_print_area_x,
                                       expected_print_area_y,
                                       expected_print_area_z)

        self.assertConfigurationEqual(
            expected_config,
            self.mock_configuration_manager.save.mock_calls[0][1][0])
    def test_get_points_should_load_points(self, *args):
        self.setup_mocks(args)
        expected_lower = {
            (1.0, 1.0): (1.0, 1.0),
            (0.0, 1.0): (-1.0, 1.0),
            (1.0, 0.0): (1.0, -1.0),
            (0.0, 0.0): (-1.0, -1.0)
        }
        expected_upper = {
            (1.0, 1.0): (1.0, 1.0),
            (0.0, 1.0): (-1.0, 1.0),
            (1.0, 0.0): (1.0, -1.0),
            (0.0, 0.0): (-1.0, -1.0)
        }
        expected_height = 1.1
        config = self.default_config
        config.calibration.height = expected_height
        config.calibration.lower_points = expected_lower
        config.calibration.upper_points = expected_upper

        self.mock_configuration_manager.load.return_value = config

        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        lower_points_result = calibration_api.get_lower_points()
        upper_points_result = calibration_api.get_upper_points()
        height_result = calibration_api.get_height()

        self.assertEquals(expected_height, height_result)
        self.assertEquals(expected_lower, lower_points_result)
        self.assertEquals(expected_upper, upper_points_result)
    def test_current_calibration_returns_the_existing_configuration(self, *args):
        self.setup_mocks(args)
        expected_config = self.default_config
        self.mock_configuration_manager.load.return_value = expected_config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        self.assertEqual(calibration_api.current_calibration(), expected_config.calibration)
    def test_change_pattern_should_change_pattern_on_controller(self, mock_HilbertGenerator, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config

        calibration_api = CalibrationAPI(self.mock_configuration_manager)
        calibration_api.show_test_pattern("Hilbert Space Filling Curve")
        self.mock_controller.change_generator.assert_called_with(self.mock_hilbert_generator)
    def test_get_patterns_should_return_available_test_patterns(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        patterns = calibration_api.get_test_patterns()

        self.assertEquals(set(['Memory Hourglass', 'NESW', 'Damping Test', 'Hilbert Space Filling Curve', 'Spiral', 'Square', 'Circle', 'Twitch']),set(patterns))
    def test_stop_should_call_stop_on_controller(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.close()

        self.mock_controller.close.assert_called_with()
    def test_stop_should_call_stop_on_controller(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.close()

        self.mock_controller.close.assert_called_with()
    def test_change_pattern_should_raise_exception_when_test_patterns_unavailable(
            self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        with self.assertRaises(Exception):
            calibration_api.show_test_pattern("Shrubberies")
    def test_show_scale_should_use_Square_Generator_and_Tuning_Transformer(self, mock_SquareGenerator, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.show_scale()

        self.mock_controller.change_generator.assert_called_with(self.mock_scale_generator)
        self.mock_path_to_audio.set_transformer.assert_called_with(self.mock_tuning_transformer)
    def test_current_calibration_returns_the_existing_configuration(
            self, *args):
        self.setup_mocks(args)
        expected_config = self.default_config
        self.mock_configuration_manager.load.return_value = expected_config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        self.assertEqual(calibration_api.current_calibration(),
                         expected_config.calibration)
    def test_change_pattern_should_change_pattern_on_controller(
            self, mock_HilbertGenerator, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config

        calibration_api = CalibrationAPI(self.mock_configuration_manager)
        calibration_api.show_test_pattern("Hilbert Space Filling Curve")
        self.mock_controller.change_generator.assert_called_with(
            self.mock_hilbert_generator)
    def test_show_point_should_replace_controllers_transformer(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.show_test_pattern('Hilbert Space Filling Curve')
        calibration_api.show_point()

        self.mock_path_to_audio.set_transformer.assert_called_with(self.mock_tuning_transformer)
    def test_show_point_should_set_coordanates_on_Single_Point_Generator(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)
        x, y, z = 1.0, 0.2, 1.0

        calibration_api.show_point([x, y, z])

        self.assertEquals([x, y], self.mock_single_point_generator.xy)
    def test_show_line_should_use_OrientationGenerator(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config

        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.show_orientation()

        self.mock_controller.change_generator.assert_called_with(self.mock_orientation_generator)
    def test_subscribe_to_status_should(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)
        mock_call_back = MagicMock()

        calibration_api.subscribe_to_status(mock_call_back)

        self.mock_UsbPacketCommunicator.return_value.register_handler.assert_called_with(PrinterStatusMessage, mock_call_back)
    def test_set_laser_override(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config

        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.set_laser_off_override(True)
        self.assertTrue(self.mock_controller.laser_off_override)
        calibration_api.set_laser_off_override(False)
        self.assertFalse(self.mock_controller.laser_off_override)
    def test_subscribe_to_status_should(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)
        mock_call_back = MagicMock()

        calibration_api.subscribe_to_status(mock_call_back)

        self.mock_UsbPacketCommunicator.return_value.register_handler.assert_called_with(
            PrinterStatusMessage, mock_call_back)
    def test_show_line_should_use_OrientationGenerator(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config

        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.show_orientation()

        self.mock_controller.change_generator.assert_called_with(
            self.mock_orientation_generator)
    def test_show_point_should_set_coordanates_on_Single_Point_Generator(
            self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)
        x, y, z = 1.0, 0.2, 1.0

        calibration_api.show_point([x, y, z])

        self.assertEquals([x, y], self.mock_single_point_generator.xy)
    def test_show_blink_should_use_blink_Generator(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config

        calibration_api = CalibrationAPI(self.mock_configuration_manager)
        x, y, z = 1.0, 0.2, 1.0

        calibration_api.show_line()
        calibration_api.show_blink([x, y, z])

        self.mock_controller.change_generator.assert_called_with(self.mock_blink_generator)
    def test_get_max_deflection_should_return_max_deflection(self, *args):
        self.setup_mocks(args)
        config = self.default_config
        expected = 0.68
        config.calibration.max_deflection = expected
        self.mock_configuration_manager.load.return_value = config

        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        actual = calibration_api.get_max_deflection()
        self.assertEquals(expected, actual)
    def test_get_max_deflection_should_return_max_deflection(self, *args):
        self.setup_mocks(args)
        config = self.default_config
        expected = 0.68
        config.calibration.max_deflection = expected
        self.mock_configuration_manager.load.return_value = config

        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        actual = calibration_api.get_max_deflection()
        self.assertEquals(expected, actual)
    def test_show_scale_should_use_Square_Generator_and_Tuning_Transformer(
            self, mock_SquareGenerator, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.show_scale()

        self.mock_controller.change_generator.assert_called_with(
            self.mock_scale_generator)
        self.mock_path_to_audio.set_transformer.assert_called_with(
            self.mock_tuning_transformer)
    def test_set_test_pattern_height_changes_height(self, *args):
        self.setup_mocks(args)

        self.mock_configuration_manager.load.return_value = self.default_config

        calibration_api = CalibrationAPI(self.mock_configuration_manager)
        calibration_api.set_test_pattern_current_height(150.0)

        self.mock_hilbert_generator.set_current_height.assert_called_with(150.0)
        self.mock_square_generator.set_current_height.assert_called_with(150.0)
        self.mock_circle_generator.set_current_height.assert_called_with(150.0)
        self.mock_spiral_generator.set_current_height.assert_called_with(150.0)
        self.mock_memory_hourglass_generator.set_current_height.assert_called_with(150.0)
    def test_get_patterns_should_return_available_test_patterns(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        patterns = calibration_api.get_test_patterns()

        self.assertEquals(
            set([
                'Memory Hourglass', 'NESW', 'Damping Test',
                'Hilbert Space Filling Curve', 'Spiral', 'Square', 'Circle',
                'Twitch'
            ]), set(patterns))
    def test_get_orientation_saves_orientation_settings(self, *args):
        self.setup_mocks(args)
        config = self.default_config

        config.calibration.flip_x_axis = True
        config.calibration.flip_y_axis = True
        config.calibration.swap_axis = True

        self.mock_configuration_manager.load.return_value = config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        result = calibration_api.get_orientation()

        self.assertEquals(result, (True, True, True))
    def test_save_points_should_save_points(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config
        expected_lower = {
            (1.0, 1.0): (1.0, 1.0),
            (0.0, 1.0): (-1.0, 1.0),
            (1.0, 0.0): (1.0, -1.0),
            (0.0, 0.0): (-1.0, -1.0)
        }
        expected_upper = {
            (1.0, 1.0): (1.0, 1.0),
            (0.0, 1.0): (-1.0, 1.0),
            (1.0, 0.0): (1.0, -1.0),
            (0.0, 0.0): (-1.0, -1.0)
        }
        expected_height = 1.1
        expected_config = self.default_config
        expected_config.calibration.height = expected_height
        expected_config.calibration.lower_points = expected_lower
        expected_config.calibration.upper_points = expected_upper

        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.set_lower_points(expected_lower)
        calibration_api.set_upper_points(expected_upper)
        calibration_api.set_height(expected_height)

        self.assertConfigurationEqual(
            expected_config,
            self.mock_configuration_manager.save.mock_calls[0][1][0])
    def test_get_print_area_saves_print_area_settings(self, *args):
        self.setup_mocks(args)
        config = self.default_config

        config.calibration.print_area_x = 20.0
        config.calibration.print_area_y = 20.0
        config.calibration.print_area_z = 20.0

        self.mock_configuration_manager.load.return_value = config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        result = calibration_api.get_print_area()

        self.assertEquals(result, (20.0, 20.0, 20.0))
    def test_set_max_deflection_should_save_and_update_max_deflection(self, *args):
        self.setup_mocks(args)
        config = self.default_config
        expected_config = self.default_config
        expected = 0.68
        expected_config.calibration.max_deflection = expected
        config.calibration.max_deflection = 0.11
        self.mock_configuration_manager.load.return_value = config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.set_max_deflection(expected)

        self.assertConfigurationEqual(expected_config, self.mock_configuration_manager.save.mock_calls[0][1][0])
        self.mock_path_to_audio.set_transformer.assert_called_with(self.mock_tuning_transformer)
    def test_set_test_pattern_speed_changes_speeds(self, *args):
        self.setup_mocks(args)

        self.mock_configuration_manager.load.return_value = self.default_config

        calibration_api = CalibrationAPI(self.mock_configuration_manager)
        calibration_api.set_test_pattern_speed(150.0)

        self.mock_hilbert_generator.set_speed.assert_called_with(150.0)
        self.mock_square_generator.set_speed.assert_called_with(150.0)
        self.mock_circle_generator.set_speed.assert_called_with(150.0)
        self.mock_spiral_generator.set_speed.assert_called_with(150.0)
        self.mock_memory_hourglass_generator.set_speed.assert_called_with(
            150.0)
    def test_get_print_area_saves_print_area_settings(self, *args):
        self.setup_mocks(args)
        config = self.default_config

        config.calibration.print_area_x = 20.0
        config.calibration.print_area_y = 20.0
        config.calibration.print_area_z = 20.0

        self.mock_configuration_manager.load.return_value = config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        result = calibration_api.get_print_area()

        self.assertEquals(result, (20.0, 20.0, 20.0))
    def test_get_orientation_saves_orientation_settings(self, *args):
        self.setup_mocks(args)
        config = self.default_config

        config.calibration.flip_x_axis = True
        config.calibration.flip_y_axis = True
        config.calibration.swap_axis = True

        self.mock_configuration_manager.load.return_value = config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        result = calibration_api.get_orientation()

        self.assertEquals(result, (True, True, True))
    def test_show_test_pattern_should_apply_calibration_should_replace_controllers_transformer(self, mock_HomogenousTransformer, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.show_test_pattern('Hilbert Space Filling Curve')

        self.mock_HomogenousTransformer.assert_called_with(
            self.default_config.calibration.max_deflection,
            self.default_config.calibration.height,
            self.default_config.calibration.lower_points,
            self.default_config.calibration.upper_points,
            )

        self.mock_path_to_audio.set_transformer.assert_called_with(self.mock_homogenous_transformer)
    def test_get_largest_object_radius_is_the_smallest_calibration_axis_at_z0(self, *args):
        self.setup_mocks(args)
        config = self.default_config
        expected = 4
        config.calibration.lower_points = {
                (1.0, 1.0): ( 7.0,  7.0),
                (0.0, 1.0): (-7.0,  7.0),
                (1.0, 0.0): ( 7.0, -7.0),
                (0.0, 0.0): (-expected, -7.0)
                }
        self.mock_configuration_manager.load.return_value = config

        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        actual = calibration_api.get_largest_object_radius()
        self.assertEquals(expected, actual)
    def test_ini_should_load_the_correct_printer(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config

        CalibrationAPI(self.mock_configuration_manager)

        self.mock_configuration_manager.load.assert_called_with()
    def test_get_largest_object_radius_is_the_smallest_calibration_axis_at_z0(
            self, *args):
        self.setup_mocks(args)
        config = self.default_config
        expected = 4
        config.calibration.lower_points = {
            (1.0, 1.0): (7.0, 7.0),
            (0.0, 1.0): (-7.0, 7.0),
            (1.0, 0.0): (7.0, -7.0),
            (0.0, 0.0): (-expected, -7.0)
        }
        self.mock_configuration_manager.load.return_value = config

        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        actual = calibration_api.get_largest_object_radius()
        self.assertEquals(expected, actual)
    def test_show_test_pattern_should_apply_calibration_should_replace_controllers_transformer(
            self, mock_HomogenousTransformer, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.show_test_pattern('Hilbert Space Filling Curve')

        self.mock_HomogenousTransformer.assert_called_with(
            self.default_config.calibration.max_deflection,
            self.default_config.calibration.height,
            self.default_config.calibration.lower_points,
            self.default_config.calibration.upper_points,
        )

        self.mock_path_to_audio.set_transformer.assert_called_with(
            self.mock_homogenous_transformer)
    def test_set_max_deflection_should_save_and_update_max_deflection(
            self, *args):
        self.setup_mocks(args)
        config = self.default_config
        expected_config = self.default_config
        expected = 0.68
        expected_config.calibration.max_deflection = expected
        config.calibration.max_deflection = 0.11
        self.mock_configuration_manager.load.return_value = config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.set_max_deflection(expected)

        self.assertConfigurationEqual(
            expected_config,
            self.mock_configuration_manager.save.mock_calls[0][1][0])
        self.mock_path_to_audio.set_transformer.assert_called_with(
            self.mock_tuning_transformer)
    def test_init_calulates_pattern_radius(self, *args):
        self.setup_mocks(args)

        self.mock_configuration_manager.load.return_value = self.default_config
        CalibrationAPI(self.mock_configuration_manager)

        self.mock_hilbert_generator.set_radius.assert_called_with(40.0)
        self.mock_square_generator.set_radius.assert_called_with(40.0)
        self.mock_circle_generator.set_radius.assert_called_with(40.0)
        self.mock_spiral_generator.set_radius.assert_called_with(40.0)
        self.mock_memory_hourglass_generator.set_radius.assert_called_with(
            40.0)
    def test_set_print_area_saves_print_area_settings(self, *args):
        self.setup_mocks(args)
        config = self.default_config
        expected_config = self.default_config
        expected_print_area_x = 20.0
        expected_print_area_y = 20.0
        expected_print_area_z = 20.0

        config.calibration.print_area_x = 12.0
        config.calibration.print_area_y = 12.0
        config.calibration.print_area_z = 12.0

        expected_config.calibration.print_area_x = 20.0
        expected_config.calibration.print_area_y = 20.0
        expected_config.calibration.print_area_z = 20.0

        self.mock_configuration_manager.load.return_value = config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.set_print_area(expected_print_area_x, expected_print_area_y, expected_print_area_z)

        self.assertConfigurationEqual(expected_config, self.mock_configuration_manager.save.mock_calls[0][1][0])
    def test_set_orientation_saves_orientation_settings(self, *args):
        self.setup_mocks(args)
        config = self.default_config
        expected_config = self.default_config
        expected_flip_x_axis = True
        expected_flip_y_axis = True
        expected_swap_axis = True

        config.calibration.flip_x_axis = False
        config.calibration.flip_y_axis = False
        config.calibration.swap_axis = False

        expected_config.calibration.flip_x_axis = True
        expected_config.calibration.flip_y_axis = True
        expected_config.calibration.swap_axis = True

        self.mock_configuration_manager.load.return_value = config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.set_orientation(expected_flip_x_axis, expected_flip_y_axis, expected_swap_axis)

        self.assertConfigurationEqual(expected_config, self.mock_configuration_manager.save.mock_calls[0][1][0])
    def test_set_laser_override(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config

        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.set_laser_off_override(True)
        self.assertTrue(self.mock_controller.laser_off_override)
        calibration_api.set_laser_off_override(False)
        self.assertFalse(self.mock_controller.laser_off_override)
    def test_show_point_should_replace_controllers_transformer(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config
        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.show_test_pattern('Hilbert Space Filling Curve')
        calibration_api.show_point()

        self.mock_path_to_audio.set_transformer.assert_called_with(
            self.mock_tuning_transformer)
    def test_show_blink_should_use_blink_Generator(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config

        calibration_api = CalibrationAPI(self.mock_configuration_manager)
        x, y, z = 1.0, 0.2, 1.0

        calibration_api.show_line()
        calibration_api.show_blink([x, y, z])

        self.mock_controller.change_generator.assert_called_with(
            self.mock_blink_generator)
    def test_init_creates_a_controller_with_digital_config(self, *args):
        self.setup_mocks(args)
        actual_samples = 77
        self.mock_micro_disseminator.samples_per_second = actual_samples
        config = self.default_config
        config.circut.circut_type = 'Digital'
        config.options.post_fire_delay = 5
        config.options.slew_delay = 5
        config.options.wait_after_move_milliseconds = 5
        self.mock_configuration_manager.load.return_value = config
        CalibrationAPI(self.mock_configuration_manager)

        self.mock_SinglePointGenerator.assert_called_with()

        self.mock_LaserControl.assert_called_with(
            self.default_config.cure_rate.override_laser_power_amount)
        self.mock_MicroDisseminator.assert_called_with(
            self.mock_laser_control, self.mock_usb_packet_communicator,
            self.default_config.circut.data_rate)

        self.mock_UsbPacketCommunicator.assert_called(
            self.default_config.circut.calibration_queue_length)

        self.mock_usb_packet_communicator.start.assert_called_with()

        self.mock_TuningTransformer.assert_called_with(
            scale=self.default_config.calibration.max_deflection)

        self.mock_PathToPoints.assert_called_with(
            actual_samples, self.mock_tuning_transformer,
            self.default_config.options.laser_thickness_mm)

        self.mock_LayerWriter.assert_called_with(self.mock_micro_disseminator,
                                                 self.mock_path_to_audio,
                                                 self.mock_laser_control,
                                                 self.mock_machine_state,
                                                 post_fire_delay_speed=100.0,
                                                 slew_delay_speed=100.0)
    def test_save_points_should_save_points(self, *args):
        self.setup_mocks(args)
        self.mock_configuration_manager.load.return_value = self.default_config
        expected_lower = {
                (1.0, 1.0): (1.0,  1.0), (0.0, 1.0): (-1.0,  1.0),
                (1.0, 0.0): (1.0, -1.0), (0.0, 0.0): (-1.0, -1.0)
                }
        expected_upper = {
                (1.0, 1.0): (1.0,  1.0), (0.0, 1.0): (-1.0,  1.0),
                (1.0, 0.0): (1.0, -1.0), (0.0, 0.0): (-1.0, -1.0)
                }
        expected_height = 1.1
        expected_config = self.default_config
        expected_config.calibration.height = expected_height
        expected_config.calibration.lower_points = expected_lower
        expected_config.calibration.upper_points = expected_upper

        calibration_api = CalibrationAPI(self.mock_configuration_manager)

        calibration_api.set_lower_points(expected_lower)
        calibration_api.set_upper_points(expected_upper)
        calibration_api.set_height(expected_height)

        self.assertConfigurationEqual(expected_config, self.mock_configuration_manager.save.mock_calls[0][1][0])
Пример #50
0
 def get_calibration_api(self, ):
     return CalibrationAPI(self._configuration_manager)