diff --git a/test/Controller_test.py b/test/Controller_test.py index 4a722adaa053afcff76db7f56fcdf85a0dbd3035..2870645ad4c2de57dc9b383f028925e419596b2d 100644 --- a/test/Controller_test.py +++ b/test/Controller_test.py @@ -33,6 +33,85 @@ def test_controller(): assert_equal(isinstance(controller._algorithm, Algorithm), True) +def test_controller_input_url(): + """Controller_test.test_controller_input_url() + + Test `--input-url` option in controller with both a URL template, and + and a simple, single file url. The latter was especially problematic after + switching to Py3 because BytesIO choked on data read in as a string. + NOTE: the bug this was designed to catch was TypeError, so a "pass" is + simply to read in the data file. There is no need to compare it + with anything. + """ + # define folder for testing + tmp_dir = gettempdir() + + # TEST 1 - read in interval using the --input-url option set to a + # URL template (i.e., it has a '{' in the string) + + # create list of string command line arguments + fake_argv = [ + "--input", + "iaga2002", + "--input-url", + "file://etc/controller/{obs}{date:%Y%m%d}_XYZF_{t}{i}.{i}", + "--observatory", + "BOU", + "--inchannels", + "X", + "Y", + "Z", + "F", + "--interval", + "minute", + "--type", + "variation", + "--output", + "iaga2002", + "--output-url", + "file://" + tmp_dir + "/{obs}{date:%Y%m%d}_XYZF_{t}{i}.{i}", + ] + + # parse arguments and create initial args object + args = parse_args(fake_argv) + + starttime1 = args.starttime = UTCDateTime("2018-10-24T00:00:00Z") + endtime1 = args.endtime = UTCDateTime("2018-10-24T00:19:00Z") + _main(args) + + # TEST 2 - read in interval using the --input-url option with no + # URL template (i.e., no '{' in the string, just a single filename) + # create list of string command line arguments + fake_argv = [ + "--input", + "iaga2002", + "--input-url", + "file://etc/controller/bou20181024_XYZF_vmin.min", + "--observatory", + "BOU", + "--inchannels", + "X", + "Y", + "Z", + "F", + "--interval", + "minute", + "--type", + "variation", + "--output", + "iaga2002", + "--output-url", + "file://" + tmp_dir + "/bou20181024_XYZF_noURL_vmin.min", + ] + + # parse arguments and create initial args object + args = parse_args(fake_argv) + + starttime1 = args.starttime = UTCDateTime("2018-10-24T00:00:00Z") + endtime1 = args.endtime = UTCDateTime("2018-10-24T00:19:00Z") + _main(args) + + def test_controller_update_sqdist(): """Controller_test.test_controller_update_sqdist().