def test_process_instructions(self):
        protocol = self.get_protocol()
        jpp = JSONProtocolProcessor(protocol)
        jpp.process_deck()
        jpp.process_head()
        jpp.process_instructions()

        api_calls = [
            get_name_from_closure(cmd.do) for cmd in self.robot._commands
        ]
        api_calls_expected = [
            'pick_up_tip', 'aspirate', 'dispense', 'delay', 'aspirate',
            'dispense', 'delay', 'drop_tip'
        ]

        self.assertEqual(api_calls, api_calls_expected)

        # self.robot.run()

        instrument = self.robot._instruments["B"]
        wells_referenced = [(i.get_parent().get_name(), i.get_name())
                            for i in instrument.placeables]
        wells_referenced_expected = [
            ('p200-rack', 'A1'),  # Location of first tip in tiprack
            ('.75 mL Tube Rack', 'A1'),  # 1st transfer
            ('.75 mL Tube Rack', 'C1'),  # 1st transfer
            ('.75 mL Tube Rack', 'A1'),  # 2nd transfer
            ('.75 mL Tube Rack', 'C1'),  # 2nd transfer
            ('trash', 'A1')  # Location of tiprack in trash
        ]
        self.assertEqual(wells_referenced, wells_referenced_expected)
    def test_process_head(self):
        protocol = self.get_protocol()
        jpp = JSONProtocolProcessor(protocol)
        jpp.process_deck()
        jpp.process_head()

        expected_settings = {
            "tip-racks": [
                self.robot._deck.containers()['p200-rack']
            ],
            "trash-container": self.robot._deck.containers()['trash'],
            "down-plunger-speed": 200,
            "up-plunger-speed": 500,
            "tip-plunge": 6,
            "extra-pull-volume": 0,
            "extra-pull-delay": 200,
            "distribute-percentage": 0.1,
            "points": [
                {
                    "f1": 1,
                    "f2": 1
                },
                {
                    "f1": 5,
                    "f2": 5
                },
                {
                    "f1": 7,
                    "f2": 7
                },
                {
                    "f1": 10,
                    "f2": 10
                }
            ]
        }

        instrument = self.robot._instruments["B"]
        head_expected = {
            'p200': {
                'instance': instrument,
                'settings': expected_settings
            }
        }

        self.assertDictEqual(head_expected, jpp.head)
        self.assertEqual(1, instrument.channels)
        self.assertEqual(0, instrument.min_volume)
        self.assertEqual(200, instrument.max_volume)
        self.assertEqual('p200', instrument.name)
    def test_process_head(self):
        protocol = self.get_protocol()
        jpp = JSONProtocolProcessor(protocol)
        jpp.process_deck()
        jpp.process_head()

        expected_settings = {
            "tip-racks": [self.robot._deck.containers()['p200-rack']],
            "trash-container":
            self.robot._deck.containers()['trash'],
            "down-plunger-speed":
            200,
            "up-plunger-speed":
            500,
            "tip-plunge":
            6,
            "extra-pull-volume":
            0,
            "extra-pull-delay":
            200,
            "distribute-percentage":
            0.1,
            "points": [{
                "f1": 1,
                "f2": 1
            }, {
                "f1": 5,
                "f2": 5
            }, {
                "f1": 7,
                "f2": 7
            }, {
                "f1": 10,
                "f2": 10
            }]
        }

        instrument = self.robot._instruments["B"]
        head_expected = {
            'p200': {
                'instance': instrument,
                'settings': expected_settings
            }
        }

        self.assertDictEqual(head_expected, jpp.head)
        self.assertEqual(1, instrument.channels)
        self.assertEqual(0, instrument.min_volume)
        self.assertEqual(200, instrument.max_volume)
        self.assertEqual('p200', instrument.name)
    def test_process_instructions(self):
        protocol = self.get_protocol()
        jpp = JSONProtocolProcessor(protocol)
        jpp.process_deck()
        jpp.process_head()
        jpp.process_instructions()

        api_calls = [
            get_name_from_closure(cmd.do)
            for cmd in self.robot._commands
        ]
        api_calls_expected = [
            'pick_up_tip',
            'aspirate',
            'dispense',
            'delay',
            'aspirate',
            'dispense',
            'delay',
            'drop_tip'
        ]

        self.assertEqual(api_calls, api_calls_expected)

        # self.robot.run()

        instrument = self.robot._instruments["B"]
        wells_referenced = [
            (i.get_parent().get_name(), i.get_name())
            for i in instrument.placeables
        ]
        wells_referenced_expected = [
            ('p200-rack', 'A1'),  # Location of first tip in tiprack
            ('.75 mL Tube Rack', 'A1'),  # 1st transfer
            ('.75 mL Tube Rack', 'C1'),  # 1st transfer
            ('.75 mL Tube Rack', 'A1'),  # 2nd transfer
            ('.75 mL Tube Rack', 'C1'),  # 2nd transfer
            ('B2', 'trash')  # Location of tiprack in trash
        ]
        self.assertEqual(wells_referenced, wells_referenced_expected)