def test_agc(self, load_patch, agc_patch): load_patch.return_value = [MagicMock()] window = 10 impproc.sys.argv = ['dummy', 'agc', 'dummy.mat', '-window', str(window)] impproc.main() self.assertTrue(agc_patch.called) aca, kwca = agc_patch.call_args self.assertEqual(kwca['window'], window) window = 50 impproc.sys.argv = ['dummy', 'agc', 'dummy.mat', '-window', str(window)] impproc.main() self.assertTrue(agc_patch.called) aca, kwca = agc_patch.call_args self.assertEqual(kwca['window'], window) with self.assertRaises(SystemExit): impproc.sys.argv = ['dummy', 'agc', 'dummy.mat', '-window', '10.1'] impproc.main() with self.assertRaises(SystemExit): impproc.sys.argv = ['dummy', 'agc', 'dummy.mat', '-window', 'badint'] impproc.main()
def test_restack(self, load_patch, restack_patch): load_patch.return_value = [MagicMock()] interval = 3 impproc.sys.argv = ['dummy', 'restack', str(interval), 'dummy.mat'] impproc.main() self.assertTrue(restack_patch.called) aca, kwca = restack_patch.call_args self.assertEqual(kwca['traces'], interval) argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = ['dummy', 'restack', 'bad', 'dummy.mat'] impproc.main() argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = ['dummy', 'restack', '0.1', 'dummy.mat'] impproc.main()
def test_rgain(self, load_patch, rgain_patch): load_patch.return_value = [MagicMock()] impproc.sys.argv = ['dummy', 'rgain', 'dummy.mat'] impproc.main() self.assertTrue(rgain_patch.called) slope = 10 impproc.sys.argv = [ 'dummy', 'rgain', '-slope', str(slope), 'dummy.mat' ] impproc.main() aca, kwca = rgain_patch.call_args self.assertEqual(kwca['slope'], slope) argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'rgain', '-slope', 'bad', 'dummy.mat' ] impproc.main()
def test_hfilt(self, load_patch, hfilt_patch): load_patch.return_value = [MagicMock()] impproc.sys.argv = ['dummy', 'hfilt', '10', '20', 'dummy.mat'] impproc.main() self.assertTrue(hfilt_patch.called) aca, kwca = hfilt_patch.call_args self.assertEqual(kwca['start_trace'], 10) self.assertEqual(kwca['end_trace'], 20) argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'hfilt', '10', 'dummy', 'dummy.mat' ] impproc.main() argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'hfilt', 'dummy', '10', 'dummy.mat' ] impproc.main()
def test_migrateTypes(self, load_patch, migrate_patch): load_patch.return_value = [MagicMock()] impproc.sys.argv = ['dummy', 'migrate', 'dummy.mat'] impproc.main() self.assertTrue(migrate_patch.called) # mtype tests for mtype in [ 'stolt', 'kirch', 'phsh', 'tk', 'sustolt', 'sumigtk', 'sumigffd' ]: impproc.sys.argv = [ 'dummy', 'migrate', '--mtype', mtype, 'dummy.mat' ] impproc.main() aca, kwca = migrate_patch.call_args self.assertEqual(kwca['mtype'], mtype) argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'migrate', '--mtype', 'bad', 'dummy.mat' ] impproc.main() impproc.sys.argv = ['dummy', 'migrate', '--nearfield', 'dummy.mat'] impproc.main() aca, kwca = migrate_patch.call_args self.assertEqual(kwca['nearfield'], True) badint = 0.1 goodint = 10 worseint = 'hello' impproc.sys.argv = [ 'dummy', 'migrate', '--htaper', str(goodint), 'dummy.mat' ] impproc.main() aca, kwca = migrate_patch.call_args self.assertEqual(kwca['htaper'], goodint) argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'migrate', '--htaper', str(badint), 'dummy.mat' ] impproc.main() argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'migrate', '--htaper', str(worseint), 'dummy.mat' ] impproc.main() impproc.sys.argv = [ 'dummy', 'migrate', '--vtaper', str(goodint), 'dummy.mat' ] impproc.main() aca, kwca = migrate_patch.call_args self.assertEqual(kwca['vtaper'], goodint) argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'migrate', '--vtaper', str(badint), 'dummy.mat' ] impproc.main() argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'migrate', '--vtaper', str(worseint), 'dummy.mat' ] impproc.main() impproc.sys.argv = [ 'dummy', 'migrate', '--nxpad', str(goodint), 'dummy.mat' ] impproc.main() aca, kwca = migrate_patch.call_args self.assertEqual(kwca['nxpad'], goodint) argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'migrate', '--nxpad', str(badint), 'dummy.mat' ] impproc.main() argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'migrate', '--nxpad', str(worseint), 'dummy.mat' ] impproc.main() impproc.sys.argv = [ 'dummy', 'migrate', '--tmig', str(goodint), 'dummy.mat' ] impproc.main() aca, kwca = migrate_patch.call_args self.assertEqual(kwca['tmig'], goodint) argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'migrate', '--tmig', str(badint), 'dummy.mat' ] impproc.main() argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'migrate', '--tmig', str(worseint), 'dummy.mat' ] impproc.main() impproc.sys.argv = [ 'dummy', 'migrate', '--verbose', str(goodint), 'dummy.mat' ] impproc.main() aca, kwca = migrate_patch.call_args self.assertEqual(kwca['verbose'], goodint) argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'migrate', '--verbose', str(badint), 'dummy.mat' ] impproc.main() argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'migrate', '--verbose', str(worseint), 'dummy.mat' ] impproc.main() impproc.sys.argv = [ 'dummy', 'migrate', '--vel', str(goodint), 'dummy.mat' ] impproc.main() aca, kwca = migrate_patch.call_args self.assertEqual(kwca['vel'], goodint) argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'migrate', '--vel', 'dummy', 'dummy.mat' ] impproc.main() impproc.sys.argv = [ 'dummy', 'migrate', '--vel_fn', str(goodint), 'dummy.mat' ] impproc.main() aca, kwca = migrate_patch.call_args self.assertEqual(kwca['vel_fn'], str(goodint))
def test_elev(self, load_patch, elev_patch): load_patch.return_value = [MagicMock()] impproc.sys.argv = ['dummy', 'elev', 'dummy.mat'] impproc.main() self.assertTrue(elev_patch.called)
def test_cat(self, load_patch, cat_patch): load_patch.return_value = [MagicMock()] impproc.sys.argv = ['dummy', 'cat', 'dummy.mat', 'dummy.mat'] impproc.main() self.assertTrue(cat_patch.called)
def test_interp(self, load_patch, interp_patch): load_patch.return_value = [MagicMock()] spacing = 10. impproc.sys.argv = ['dummy', 'interp', str(spacing), 'dummy.mat'] impproc.main() self.assertTrue(interp_patch.called) aca, kwca = interp_patch.call_args self.assertEqual(kwca['spacing'], spacing) self.assertEqual(kwca['extrapolate'], False) argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'interp', 'dummy.mat', os.path.join(THIS_DIR, 'input_data', 'small_data.mat') ] impproc.main() impproc.sys.argv = [ 'dummy', 'interp', '--gps_fn', 'dummy', str(spacing), 'dummy.mat' ] impproc.main() aca, kwca = interp_patch.call_args self.assertEqual(kwca['spacing'], spacing) self.assertEqual(kwca['gps_fn'], 'dummy') impproc.sys.argv = [ 'dummy', 'interp', '--offset', str(10), str(spacing), 'dummy.mat' ] impproc.main() aca, kwca = interp_patch.call_args self.assertEqual(kwca['spacing'], spacing) self.assertEqual(kwca['offset'], 10.) argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'interp', '--offset', 'badfloat', str(spacing), 'dummy.mat' ] impproc.main() impproc.sys.argv = [ 'dummy', 'interp', '--minmove', str(10), str(spacing), 'dummy.mat' ] impproc.main() aca, kwca = interp_patch.call_args self.assertEqual(kwca['spacing'], spacing) self.assertEqual(kwca['minmove'], 10.) argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'interp', '--minmove', 'badfloat', str(spacing), 'dummy.mat' ] impproc.main() impproc.sys.argv = [ 'dummy', 'interp', '--extrapolate', str(spacing), 'dummy.mat' ] impproc.main() aca, kwca = interp_patch.call_args self.assertEqual(kwca['spacing'], spacing) self.assertEqual(kwca['extrapolate'], True)
def test_nmo(self, load_patch, nmo_patch): load_patch.return_value = [MagicMock()] sep = 123.4 impproc.sys.argv = ['dummy', 'nmo', str(sep), 'dummy.mat'] impproc.main() self.assertTrue(nmo_patch.called) aca, kwca = nmo_patch.call_args self.assertEqual(kwca['ant_sep'], sep) impproc.sys.argv = [ 'dummy', 'nmo', '--uice', str(10), str(sep), 'dummy.mat' ] impproc.main() aca, kwca = nmo_patch.call_args self.assertEqual(kwca['ant_sep'], sep) self.assertEqual(kwca['uice'], 10.) argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'nmo', '--uice', 'badvel', str(sep), 'dummy.mat' ] impproc.main() impproc.sys.argv = [ 'dummy', 'nmo', '--uair', str(10), str(sep), 'dummy.mat' ] impproc.main() aca, kwca = nmo_patch.call_args self.assertEqual(kwca['ant_sep'], sep) self.assertEqual(kwca['uair'], 10.) argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = [ 'dummy', 'nmo', '--uair', 'badvel', str(sep), 'dummy.mat' ] impproc.main() argparse_mock = MagicMock() with patch('argparse.ArgumentParser._print_message', argparse_mock): with self.assertRaises(SystemExit): impproc.sys.argv = ['dummy', 'nmo', 'dummy.mat', str(sep)] impproc.main()