diff --git a/test/edge_test/EdgeFactory_test.py b/test/edge_test/EdgeFactory_test.py index 55e94f1266fef85c9f6b0cdafa15b781420d656e..7f92b7ecc2abf0a3b07d92525157bcb4875dff97 100644 --- a/test/edge_test/EdgeFactory_test.py +++ b/test/edge_test/EdgeFactory_test.py @@ -5,7 +5,7 @@ from geomagio.edge import EdgeFactory from numpy.testing import assert_equal -def dont_get_timeseries(): +def test_get_timeseries(): """edge_test.EdgeFactory_test.test_get_timeseries()""" # Call get_timeseries, and test stats for comfirmation that it came back. # TODO, need to pass in host and port from a config file, or manually @@ -29,6 +29,35 @@ def dont_get_timeseries(): "H", "Expect timeseries stats channel to be equal to H", ) + assert_equal( + timeseries.select(channel="H")[0].stats.data_type, + "variation", + "Expect timeseries stats data_type to be equal to variation", + ) + # timeseries requested with location code as type + timeseries = edge_factory.get_timeseries( + UTCDateTime(2015, 3, 1, 0, 0, 0), + UTCDateTime(2015, 3, 1, 1, 0, 0), + "BOU", + ("H"), + "R0", + "minute", + ) + assert_equal( + timeseries.select(channel="H")[0].stats.station, + "BOU", + "Expect timeseries to have stats", + ) + assert_equal( + timeseries.select(channel="H")[0].stats.channel, + "H", + "Expect timeseries stats channel to be equal to H", + ) + assert_equal( + timeseries.select(channel="H")[0].stats.data_type, + "variation", + "Expect timeseries stats data_type to be equal to variation", + ) def test_add_empty_channels(): diff --git a/test/edge_test/MiniSeedFactory_test.py b/test/edge_test/MiniSeedFactory_test.py index 5689d69c5246c972913963eeac11f9fae9ca7ca2..22475d60b915a27753b80355e89af31c07065753 100644 --- a/test/edge_test/MiniSeedFactory_test.py +++ b/test/edge_test/MiniSeedFactory_test.py @@ -1,9 +1,11 @@ """Tests for MiniSeedFactory.py""" import io +from test.edge_test.conftest import MockMiniSeedClient import numpy from numpy.testing import assert_equal from obspy.core import read, Stats, Stream, Trace, UTCDateTime +import pytest from geomagio import TimeseriesUtility from geomagio.edge import MiniSeedFactory, MiniSeedInputClient @@ -85,14 +87,14 @@ def test__set_metadata(): assert_equal(stream[1].stats["channel"], "H") -# def test_get_timeseries(): -def dont_get_timeseries(): +def test_get_timeseries(MockMiniSeedClient): """edge_test.MiniSeedFactory_test.test_get_timeseries()""" # Call get_timeseries, and test stats for comfirmation that it came back. # TODO, need to pass in host and port from a config file, or manually # change for a single test. - edge_factory = MiniSeedFactory(host="TODO", port="TODO") - timeseries = edge_factory.get_timeseries( + miniseed_factory = MiniSeedFactory() + miniseed_factory.client = MockMiniSeedClient() + timeseries = miniseed_factory.get_timeseries( UTCDateTime(2015, 3, 1, 0, 0, 0), UTCDateTime(2015, 3, 1, 1, 0, 0), "BOU", @@ -110,6 +112,35 @@ def dont_get_timeseries(): "H", "Expect timeseries stats channel to be equal to H", ) + assert_equal( + timeseries.select(channel="H")[0].stats.data_type, + "variation", + "Expect timeseries stats data_type to be equal to variation", + ) + # timeseries requested with location code as type + timeseries = miniseed_factory.get_timeseries( + UTCDateTime(2015, 3, 1, 0, 0, 0), + UTCDateTime(2015, 3, 1, 1, 0, 0), + "BOU", + ("H"), + "R0", + "minute", + ) + assert_equal( + timeseries.select(channel="H")[0].stats.station, + "BOU", + "Expect timeseries to have stats", + ) + assert_equal( + timeseries.select(channel="H")[0].stats.channel, + "H", + "Expect timeseries stats channel to be equal to H", + ) + assert_equal( + timeseries.select(channel="H")[0].stats.data_type, + "variation", + "Expect timeseries stats data_type to be equal to variation", + ) def __create_trace(