def test_convert(self):
        deck = self.generate_deck()
        calibration_data = {
            'A1': {
                'type': 'Slot',
                'delta': (1, 1, 1),
                'children': {
                    'tube_rack': {
                        'type': 'tube-rack-2ml',
                        'delta': (1, 1, 1),
                        'children': {
                            'Red': {
                                'type': 'Well',
                                'delta': (1, 1, 1)
                            },
                            'Blue': {
                                'type': 'Well',
                                'delta': (2, 2, 2)
                            }
                        }
                    }
                }
            }
        }
        my_calibrator = Calibrator(deck, calibration_data)
        res = my_calibrator.convert(deck['A1']['tube_rack']['Blue'],
                                    deck['A1']['tube_rack']['Blue'].center())
        self.assertEqual(res, (29.0, 24.0, 4.0))

        res = my_calibrator.convert(deck['A1']['tube_rack'])
        self.assertEqual(res, (7, 12, 2))
    def test_apply_calibration(self):
        deck = self.generate_deck()
        calibration_data = {
            'A1': {
                'type': 'Slot',
                'delta': (1, 1, 1),
                'children': {
                    'tube_rack': {
                        'type': 'tube-rack-2ml',
                        'delta': (1, 1, 1),
                        'children': {
                            'Red': {
                                'type': 'Well',
                                'delta': (1, 1, 1)
                            },
                            'Blue': {
                                'type': 'Well',
                                'delta': (2, 2, 2)
                            }
                        }
                    }
                }
            }
        }
        my_calibrator = Calibrator(deck, calibration_data)

        red = deck['A1']['tube_rack']['Red']
        blue = deck['A1']['tube_rack']['Blue']

        self.assertEqual(my_calibrator.convert(red), (13, 18, 3))
        self.assertEqual(my_calibrator.convert(blue), (24, 19, 4))
    def test_convert(self):
        deck = self.generate_deck()
        calibration_data = {
            'A1':
            {
                'delta': (1, 1, 1),
                'children': {
                    'tube_rack': {
                        'delta': (1, 1, 1),
                        'children': {
                            'Red':
                            {
                                'delta': (1, 1, 1)
                            },
                            'Blue':
                            {
                                'delta': (2, 2, 2)
                            }
                        }
                    }
                }
            }
        }
        my_calibrator = Calibrator(deck, calibration_data)
        res = my_calibrator.convert(
            deck['A1']['tube_rack']['Blue'],
            deck['A1']['tube_rack']['Blue'].center())
        self.assertEqual(res, (29.0, 24.0, 4.0))

        res = my_calibrator.convert(
            deck['A1']['tube_rack'])
        self.assertEqual(res, (7, 12, 2))
    def test_apply_calibration(self):
        deck = self.generate_deck()
        calibration_data = {
            'A1':
            {
                'delta': (1, 1, 1),
                'children': {
                    'tube_rack': {
                        'delta': (1, 1, 1),
                        'children': {
                            'Red':
                            {
                                'delta': (1, 1, 1)
                            },
                            'Blue':
                            {
                                'delta': (2, 2, 2)
                            }
                        }
                    }
                }
            }
        }
        my_calibrator = Calibrator(deck, calibration_data)

        red = deck['A1']['tube_rack']['Red']
        blue = deck['A1']['tube_rack']['Blue']

        self.assertEqual(
            my_calibrator.convert(red),
            (13, 18, 3))
        self.assertEqual(
            my_calibrator.convert(blue),
            (24, 19, 4))
    def test_calibrate(self):
        deck = self.generate_deck()
        calibration_data = {}
        my_calibrator = Calibrator(deck, calibration_data)

        current_position = (14, 19, -1)
        tube_rack = deck['A1']['tube_rack']
        expected = tube_rack['Red'].center(tube_rack)

        new_calibration_data = my_calibrator.calibrate(
            calibration_data, (deck['A1']['tube_rack'], expected),
            current_position)

        expected_result = {
            'A1': {
                'children': {
                    'tube_rack': {
                        'delta': (-1.0, -1.0, -1.0),
                        'type': 'Container'
                    }
                }
            }
        }
        self.assertDictEqual(new_calibration_data, expected_result)

        red = deck['A1']['tube_rack']['Red']
        self.assertEqual(
            my_calibrator.convert(red) + red.center(), current_position)
    def test_calibrate(self):
        deck = self.generate_deck()
        calibration_data = {}
        my_calibrator = Calibrator(deck, calibration_data)

        current_position = (14, 19, -1)
        tube_rack = deck['A1']['tube_rack']
        expected = tube_rack['Red'].center(tube_rack)

        new_calibration_data = my_calibrator.calibrate(
            calibration_data,
            (deck['A1']['tube_rack'], expected),
            current_position)

        expected_result = {
            'A1': {
                'children': {
                    'tube_rack': {
                        'delta': (-1.0, -1.0, -1.0)
                    }
                }
            }
        }
        self.assertDictEqual(new_calibration_data, expected_result)

        red = deck['A1']['tube_rack']['Red']
        self.assertEqual(
            my_calibrator.convert(red) + red.center(),
            current_position)