From 5bf9572025b3c64c9e32abb9595904f6446830da Mon Sep 17 00:00:00 2001
From: pcain <pcain@usgs.gov>
Date: Wed, 1 Sep 2021 10:18:47 -0600
Subject: [PATCH] mseed/edge factories should set type to SNCL type

---
 test/edge_test/EdgeFactory_test.py     | 31 +++++++++++++++++++-
 test/edge_test/MiniSeedFactory_test.py | 39 +++++++++++++++++++++++---
 2 files changed, 65 insertions(+), 5 deletions(-)

diff --git a/test/edge_test/EdgeFactory_test.py b/test/edge_test/EdgeFactory_test.py
index 55e94f126..7f92b7ecc 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 5689d69c5..22475d60b 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(
-- 
GitLab