From c394d6b9faabd44733f2b325658c7e3e5d2055d3 Mon Sep 17 00:00:00 2001 From: Jeremy Fee <jmfee@usgs.gov> Date: Tue, 17 Dec 2019 13:52:06 -0700 Subject: [PATCH] Add test to call get_tag, fix get_tag issue on python 2 --- geomagio/edge/RawInputClient.py | 2 +- ...putFactory_test.py => RawInputClient_test.py} | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) rename test/edge_test/{RawInputFactory_test.py => RawInputClient_test.py} (75%) diff --git a/geomagio/edge/RawInputClient.py b/geomagio/edge/RawInputClient.py index 436102f63..f2a2f3bcf 100644 --- a/geomagio/edge/RawInputClient.py +++ b/geomagio/edge/RawInputClient.py @@ -375,7 +375,7 @@ class RawInputClient(): The Packet is right padded with zeros The Packet must be 40 Bytes long. """ - tg = self.tag + ' ' + tg = str(self.tag + ' ').encode() tb = struct.pack(TAGSTR, PACKETHEAD, TAG, tg[:12], 0, 0, 0, 0, 0, 0) return tb diff --git a/test/edge_test/RawInputFactory_test.py b/test/edge_test/RawInputClient_test.py similarity index 75% rename from test/edge_test/RawInputFactory_test.py rename to test/edge_test/RawInputClient_test.py index c78d654ea..9fd9bd14f 100644 --- a/test/edge_test/RawInputFactory_test.py +++ b/test/edge_test/RawInputClient_test.py @@ -1,4 +1,4 @@ -"""Tests for RawInputFactory.py""" +"""Tests for RawInputClient.py""" import numpy from obspy.core import Stats, Trace, UTCDateTime @@ -45,3 +45,17 @@ def test_raw_input_client(): client.send_trace('minute', trace_send) # verify data was sent assert_equals(len(client.last_send), 1) + + +def test__get_tag(): + """edge_test.RawInputClient_test.test_raw_input_client() + """ + network = 'NT' + station = 'BOU' + channel = 'MVH' + location = 'R0' + client = TestRawInputClient(tag='tag', host='host', port='port', + station=station, channel=channel, + location=location, network=network) + tag_send = client._get_tag() + assert_equals(tag_send is not None, True) -- GitLab