def test_deprecated_parser(self, print_result, list_nodes, flash, reset):
        """Run deprecated subparsers."""
        reset.return_value = flash.return_value = {'result': 'test'}
        list_nodes.return_value = self._nodes

        # call deprecated subparser
        args = ['reset-m3', '-h']
        self.assertRaises(SystemExit, open_linux_parser.main, args)

        args = ['flash-m3', 'firmware.elf', '-l', 'saclay,a8,1-5']
        open_linux_parser.main(args)
        print_result.assert_called()
        args, _ = print_result.call_args
        self.assertEqual(len(args), 3)
        self.assertEqual(args[0], {'result': 'test'})
        self.assertEqual(args[1], None)
        self.assertEqual(args[2], None)

        args = ['reset-m3', '-l', 'saclay,a8,1-5']
        open_linux_parser.main(args)
        print_result.assert_called()
        args, _ = print_result.call_args
        self.assertEqual(len(args), 3)
        self.assertEqual(args[0], {'result': 'test'})
        self.assertEqual(args[1], None)
        self.assertEqual(args[2], None)
    def test_main_reset(self, list_nodes, reset):
        """Run the parser.node.main with reset subparser function."""
        reset.return_value = {'result': 'test'}
        list_nodes.return_value = self._nodes

        args = ['reset', '-l', 'saclay,a8,1-5']
        open_linux_parser.main(args)
        list_nodes.assert_called_with(self.api, 123, [self._nodes], None)
        reset.assert_called_with({
            'user': '******',
            'exp_id': 123
        },
                                 self._root_nodes,
                                 verbose=False)

        exp_info_res = {
            "items": [{
                "network_address": node
            } for node in self._nodes]
        }
        with patch.object(self.api, 'get_experiment_info',
                          Mock(return_value=exp_info_res)):
            list_nodes.return_value = []
            args = ['reset']
            open_linux_parser.main(args)
            list_nodes.assert_called_with(self.api, 123, None, None)
            reset.assert_called_with({
                'user': '******',
                'exp_id': 123
            },
                                     self._root_nodes,
                                     verbose=False)
    def test_reset_jmespath(self, print_result, list_nodes, reset):
        """Run reset subparser function with jmespath options."""
        reset.return_value = {'result': 'test'}
        list_nodes.return_value = self._nodes

        args = [
            '--jmespath=\'test\'', '--fmt=\'int\'', 'reset', '-l',
            'saclay,a8,1-5'
        ]
        open_linux_parser.main(args)

        print_result.assert_called_once()
        args, _ = print_result.call_args
        self.assertEqual(len(args), 3)
        self.assertEqual(args[0], {'result': 'test'})
        self.assertTrue(isinstance(args[1], jmespath.parser.ParsedResult))
        self.assertEqual(args[2], 'int')