Пример #1
0
    def test_get_timeseries(self):
        try:  # can't use decorator because this method gets called
            import nds2
        except ImportError as e:
            pytest.skip(str(e))
        product, parser = self.test_init_cli()
        args = parser.parse_args(self.TEST_ARGS + ['--out', TEMP_PLOT_FILE])
        product.post_arg(args)

        random.seed(0)
        xts = TimeSeries(random.rand(10240),
                         t0=1000000000,
                         sample_rate=1024,
                         name='X1:TEST-CHANNEL')
        yts = TimeSeries(random.rand(10240),
                         t0=1000000000,
                         sample_rate=1024,
                         name='Y1:TEST-CHANNEL')
        nds_connection = mocks.nds2_connection(buffers=[
            mocks.nds2_buffer_from_timeseries(xts),
            mocks.nds2_buffer_from_timeseries(yts),
        ])
        with mock.patch('nds2.connection') as mock_connection, \
                mock.patch('nds2.buffer'):
            mock_connection.return_value = nds_connection

            product.getTimeSeries(args)

        assert len(product.timeseries) == (len(product.chan_list) *
                                           len(product.start_list))

        return product, args
Пример #2
0
    def test_get_timeseries(self):
        try:  # can't use decorator because this method gets called
            import nds2
        except ImportError as e:
            pytest.skip(str(e))
        product, parser = self.test_init_cli()
        args = parser.parse_args(self.TEST_ARGS + ['--out', TEMP_PLOT_FILE])
        product.post_arg(args)

        random.seed(0)
        xts = TimeSeries(random.rand(10240), t0=1000000000,
                         sample_rate=1024, name='X1:TEST-CHANNEL')
        yts = TimeSeries(random.rand(10240), t0=1000000000,
                         sample_rate=1024, name='Y1:TEST-CHANNEL')
        nds_connection = mocks.nds2_connection(buffers=[
            mocks.nds2_buffer_from_timeseries(xts),
            mocks.nds2_buffer_from_timeseries(yts),
        ])
        with mock.patch('nds2.connection') as mock_connection, \
                mock.patch('nds2.buffer'):
            mock_connection.return_value = nds_connection

            product.getTimeSeries(args)

        assert len(product.timeseries) == (len(product.chan_list) *
                                           len(product.start_list))

        return product, args
Пример #3
0
    def test_makePlot(self):
        product, parser = self.test_init_cli()
        args = parser.parse_args(self.TEST_ARGS + ['--out', TEMP_PLOT_FILE])
        product.post_arg(args)
        args.interactive = True

        random.seed(0)
        xts = TimeSeries(random.rand(10240),
                         t0=1000000000,
                         sample_rate=1024,
                         name='X1:TEST-CHANNEL')
        yts = TimeSeries(random.rand(10240),
                         t0=1000000000,
                         sample_rate=1024,
                         name='Y1:TEST-CHANNEL')
        nds_connection = mocks.nds2_connection(buffers=[
            mocks.nds2_buffer_from_timeseries(xts),
            mocks.nds2_buffer_from_timeseries(yts),
        ])

        with mock.patch('nds2.connection') as mock_connection, \
                mock.patch('nds2.buffer'):
            mock_connection.return_value = nds_connection

            try:
                product.makePlot(args, parser)
            finally:
                if os.path.isfile(args.out):
                    os.remove(args.out)

        assert product.is_interactive is True
Пример #4
0
    def test_makePlot(self):
        product, parser = self.test_init_cli()
        args = parser.parse_args(self.TEST_ARGS + ['--out', TEMP_PLOT_FILE])
        product.post_arg(args)
        args.interactive = True

        random.seed(0)
        xts = TimeSeries(random.rand(10240), t0=1000000000,
                         sample_rate=1024, name='X1:TEST-CHANNEL')
        yts = TimeSeries(random.rand(10240), t0=1000000000,
                         sample_rate=1024, name='Y1:TEST-CHANNEL')
        nds_connection = mocks.nds2_connection(buffers=[
            mocks.nds2_buffer_from_timeseries(xts),
            mocks.nds2_buffer_from_timeseries(yts),
        ])

        with mock.patch('nds2.connection') as mock_connection, \
                mock.patch('nds2.buffer'):
            mock_connection.return_value = nds_connection

            try:
                product.makePlot(args, parser)
            finally:
                if os.path.isfile(args.out):
                    os.remove(args.out)

        assert product.is_interactive is True
Пример #5
0
 def test_fetch(self):
     ts = self.create(name='X1:TEST', t0=1000000000, unit='m')
     nds_buffer = mocks.nds2_buffer_from_timeseries(ts)
     nds_connection = mocks.nds2_connection(buffers=[nds_buffer])
     with mock.patch('nds2.connection') as mock_connection, \
             mock.patch('nds2.buffer', nds_buffer):
         mock_connection.return_value = nds_connection
         # use verbose=True to hit more lines
         ts2 = self.TEST_CLASS.fetch('X1:TEST', *ts.span, verbose=True)
         # check open connection works
         ts2 = self.TEST_CLASS.fetch('X1:TEST',
                                     *ts.span,
                                     verbose=True,
                                     connection=nds_connection)
     utils.assert_quantity_sub_equal(ts, ts2, exclude=['channel'])