def test_ssh_main(): """ test main parser dispatching for subcommands""" with patch('iotlabcli.parser.main.iotlabsshcli') as mocked_module: mocked_main = mocked_module.parser.open_a8_parser.main main_parser.main(['ssh', '-i', '123']) mocked_main.assert_called_with(['-i', '123'])
def test_oml_main(entry): """ test main parser dispatching for subcommands""" with patch('iotlabcli.parser.main.oml_plot_tools') as mocked_module: mocked_main = getattr(mocked_module, entry).main main_parser.main(['plot', entry, '-i', '123']) mocked_main.assert_called_with(['-i', '123'])
def test_aggregator_main(entry): """ test main parser dispatching for subcommands""" with patch('iotlabcli.parser.main.iotlabaggregator') as mocked_module: mocked_main = getattr(mocked_module, entry).main main_parser.main([entry, '-i', '123']) mocked_main.assert_called_with(['-i', '123'])
def test_ssh_main(): """ test main parser dispatching for subcommands""" with patch('iotlabcli.parser.main.iotlabsshcli') as mocked_module: mocked_main = mocked_module.parser.open_linux_parser.main main_parser.main(['ssh', '-i', '123']) mocked_main.assert_called_with(['-i', '123']) assert subprocess.check_call(['iotlab', 'ssh', '--help']) == 0
def test_main_parser_no_tools(): """tools subcommands returning""" pytest.raises(SystemExit, lambda: main_parser.main(['ssh'])) pytest.raises(SystemExit, lambda: main_parser.main(['serial'])) pytest.raises(SystemExit, lambda: main_parser.main(['sniffer'])) pytest.raises(SystemExit, lambda: main_parser.main(['plot']))
def test_help(argv, exc): """Tests that the help entrypoints print the help.""" with patch.object(argparse.ArgumentParser, 'print_help') \ as argparser_print_help, \ patch.object(sys, 'argv', argv): if exc: with pytest.raises(exc): main_parser.main() else: main_parser.main() argparser_print_help.assert_called()
def test_main_parser(entry): """ test main parser dispatching """ with patch('iotlabcli.parser.%s.main' % entry) as entrypoint_func: main_parser.main([entry, '-i', '123']) entrypoint_func.assert_called_with(['-i', '123'])
def test_main_parser_no_tools(): """tools subcommands returning""" pytest.raises(SystemExit, lambda: main_parser.main(['ssh'])) pytest.raises(SystemExit, lambda: main_parser.main(['aggregator'])) pytest.raises(SystemExit, lambda: main_parser.main(['oml-plot']))
def test_main_parser_oml_plot(): """ Experiment parser """ entry = 'plot' with patch('iotlabcli.parser.main.oml_plot') as entrypoint_func: main_parser.main([entry, '-i', '123']) entrypoint_func.assert_called_with(['-i', '123'])