def test_process(self, process_patch): impdarexec.sys.argv = ['dummy', 'proc', '-rev', 'fn.mat'] impdarexec.main() self.assertTrue(process_patch.called) aca, kwca = process_patch.call_args self.assertEqual(kwca['fn'], ['fn.mat']) self.assertEqual(kwca['rev'], True)
def test_convert(self, convert_patch): impdarexec.sys.argv = ['dummy', 'convert', 'fn.mat', 'shp'] impdarexec.main() self.assertTrue(convert_patch.called) aca, kwca = convert_patch.call_args self.assertEqual(kwca['fns_in'], ['fn.mat']) self.assertEqual(kwca['out_fmt'], 'shp') with self.assertRaises(SystemExit): impdarexec.sys.argv = ['dummy', 'convert', 'fn.mat', 'notanoutput'] impdarexec.main()
def test_load(self, load_patch): impdarexec.sys.argv = ['dummy', 'load', 'mat', 'fn.mat'] impdarexec.main() self.assertTrue(load_patch.called) aca, kwca = load_patch.call_args self.assertEqual(kwca['fns_in'], ['fn.mat']) self.assertEqual(kwca['filetype'], 'mat') with self.assertRaises(SystemExit): impdarexec.sys.argv = ['dummy', 'load', 'notanintype', 'fn.mat'] impdarexec.main()
def test_convert(self, convert_patch): impdarexec.sys.argv = ['dummy', 'convert', 'fn.mat', 'shp'] impdarexec.main() self.assertTrue(convert_patch.called) aca, kwca = convert_patch.call_args self.assertEqual(kwca['fns_in'], ['fn.mat']) self.assertEqual(kwca['out_fmt'], 'shp') argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impdarexec.sys.argv = ['dummy', 'convert', 'fn.mat', 'notanoutput'] impdarexec.main()
def test_load(self, load_patch): impdarexec.sys.argv = ['dummy', 'load', 'mat', 'fn.mat'] impdarexec.main() self.assertTrue(load_patch.called) aca, kwca = load_patch.call_args self.assertEqual(kwca['fns_in'], ['fn.mat']) self.assertEqual(kwca['filetype'], 'mat') argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impdarexec.sys.argv = ['dummy', 'load', 'notanintype', 'fn.mat'] impdarexec.main()
def test_plot(self, plot_patch): impdarexec.sys.argv = ['dummy', 'plot', 'fn.mat'] impdarexec.main() self.assertTrue(plot_patch.called) aca, kwca = plot_patch.call_args self.assertEqual(kwca['fns'], ['fn.mat'])