Repository: obspy/obspy

Issue:
clients.neic tests fail
Potentially a server side change?

``` bash
$ obspy.runtests clients.neic

Running /Users/lion/workspace/code/obspy/obspy/scripts/runtests.py, ObsPy version '1.0.2.post0+358.ged0c7fb007'
....F

======================================================================
FAIL: test_get_waveform_nscl (obspy.clients.neic.tests.test_client.ClientTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/lion/workspace/code/obspy/obspy/clients/neic/tests/test_client.py", line 93, in test_get_waveform_nscl
    self.assertEqual(st, st2)
AssertionError: <obspy.core.stream.Stream object at 0x10d8276a0> != <obspy.core.stream.Stream object at 0x10cf5a3c8>

----------------------------------------------------------------------
Ran 5 tests in 8.443s

FAILED (failures=1)
```



Discussion:
It's very unfortunate that unittest is using `repr()` for the message.. that way it's useless for streams


Resolving patch:
diff --git a/obspy/clients/syngine/__init__.py b/obspy/clients/syngine/__init__.py
--- a/obspy/clients/syngine/__init__.py
+++ b/obspy/clients/syngine/__init__.py
@@ -81,12 +81,12 @@
 ...     bulk=bulk, starttime="P-10", endtime="P+20")
 >>> print(st)  # doctest: +ELLIPSIS
 6 Trace(s) in Stream:
-XX.AA.SE.MXZ | 2010-02-27T06:48:11.500000Z - ... | 4.0 Hz, 120 samples
-XX.AA.SE.MXN | 2010-02-27T06:48:11.500000Z - ... | 4.0 Hz, 120 samples
-XX.AA.SE.MXE | 2010-02-27T06:48:11.500000Z - ... | 4.0 Hz, 120 samples
-XX.BB.SE.MXZ | 2010-02-27T06:48:15.250000Z - ... | 4.0 Hz, 120 samples
-XX.BB.SE.MXN | 2010-02-27T06:48:15.250000Z - ... | 4.0 Hz, 120 samples
-XX.BB.SE.MXE | 2010-02-27T06:48:15.250000Z - ... | 4.0 Hz, 120 samples
+XX.AA.SE.MXZ | 2010-02-27T06:48:11... - ... | 4.0 Hz, 120 samples
+XX.AA.SE.MXN | 2010-02-27T06:48:11... - ... | 4.0 Hz, 120 samples
+XX.AA.SE.MXE | 2010-02-27T06:48:11... - ... | 4.0 Hz, 120 samples
+XX.BB.SE.MXZ | 2010-02-27T06:48:15... - ... | 4.0 Hz, 120 samples
+XX.BB.SE.MXN | 2010-02-27T06:48:15... - ... | 4.0 Hz, 120 samples
+XX.BB.SE.MXE | 2010-02-27T06:48:15... - ... | 4.0 Hz, 120 samples
 
 
 Other Useful Methods


Test patch:
diff --git a/obspy/clients/arclink/tests/test_client.py b/obspy/clients/arclink/tests/test_client.py
--- a/obspy/clients/arclink/tests/test_client.py
+++ b/obspy/clients/arclink/tests/test_client.py
@@ -45,6 +45,10 @@ def test_get_waveform(self):
         start = UTCDateTime("2010-12-31T23:59:50.495000Z")
         end = start + 100
         stream = client.get_waveforms('GE', 'APE', '', 'BHE', start, end)
+        # seems the response of the server has changed, it contains two traces
+        # with an overlap now but the data is consistent and a cleanup merge
+        # works
+        stream.merge(-1)
         self.assertEqual(len(stream), 1)
         trace = stream[0]
         self.assertLessEqual(trace.stats.starttime, start)
@@ -99,68 +103,47 @@ def test_get_routing(self):
         Tests get_routing method on various ArcLink nodes.
         """
         dt = UTCDateTime(2010, 1, 1)
+        expected_routing_bw = {'BW.RJOB..': [{
+            'priority': 1, 'start': UTCDateTime(1980, 1, 1, 0, 0),
+            'host': u'erde.geophysik.uni-muenchen.de', 'end': None,
+            'port': 18001}]}
+        expected_routing_iv = {
+            'IV...': [{'priority': 1, 'start': UTCDateTime(1980, 1, 1, 0, 0),
+                       'host': 'eida.ingv.it', 'end': None,
+                       'port': 18002}]}
+        expected_routing_ge = {
+            'GE...': [{'priority': 1, 'start': UTCDateTime(1993, 1, 1, 0, 0),
+                       'host': 'eida.gfz-potsdam.de', 'end': None,
+                       'port': 18002}]}
         # 1 - BW network via erde.geophysik.uni-muenchen.de:18001
         client = Client(host="erde.geophysik.uni-muenchen.de", port=18001,
                         user='test@obspy.org')
         results = client.get_routing('BW', 'RJOB', dt, dt + 1)
-        self.assertEqual(
-            results,
-            {'BW.RJOB..': [{'priority': 1,
-                            'start': UTCDateTime(1980, 1, 1, 0, 0),
-                            'host': '141.84.11.2', 'end': None,
-                            'port': 18001}]})
+        self.assertEqual(results, expected_routing_bw)
         # 2 - BW network via webdc:18001
         client = Client(host="webdc.eu", port=18001, user='test@obspy.org')
         results = client.get_routing('BW', 'RJOB', dt, dt + 1)
-        self.assertEqual(
-            results,
-            {'BW.RJOB..': [{'priority': 1,
-                            'start': UTCDateTime(1980, 1, 1, 0, 0),
-                            'host': '141.84.11.2',
-                            'end': None,
-                            'port': 18001}]})
+        self.assertEqual(results, expected_routing_bw)
         # 3 - BW network via webdc:18002
         client = Client(host="webdc.eu", port=18002, user='test@obspy.org')
         results = client.get_routing('BW', 'RJOB', dt, dt + 1)
-        self.assertEqual(
-            results,
-            {'BW.RJOB..': [{'priority': 1,
-                            'start': UTCDateTime(1980, 1, 1, 0, 0),
-                            'host': '141.84.11.2',
-                            'end': None,
-                            'port': 18001}]})
+        self.assertEqual(results, expected_routing_bw)
         # 4 - IV network via webdc.eu:18001
         client = Client(host="webdc.eu", port=18001, user='test@obspy.org')
         results = client.get_routing('IV', '', dt, dt + 1)
-        self.assertEqual(
-            results,
-            {'IV...': [{'priority': 1, 'start': UTCDateTime(1980, 1, 1, 0, 0),
-                        'host': 'eida.rm.ingv.it', 'end': None,
-                        'port': 18002}]})
+        self.assertEqual(results, expected_routing_iv)
         # 5 - IV network via webdc.eu:18002
         client = Client(host="webdc.eu", port=18002, user='test@obspy.org')
         results = client.get_routing('IV', '', dt, dt + 1)
-        self.assertEqual(
-            results,
-            {'IV...': [{'priority': 1, 'start': UTCDateTime(1980, 1, 1, 0, 0),
-                        'host': 'eida.rm.ingv.it', 'end': None,
-                        'port': 18002}]})
+        self.assertEqual(results, expected_routing_iv)
         # 6 - GE.APE via webdc.eu:18001
         client = Client(host="webdc.eu", port=18001, user='test@obspy.org')
         results = client.get_routing('GE', 'APE', dt, dt + 1)
-        self.assertEqual(
-            results,
-            {'GE...': [{'priority': 1, 'start': UTCDateTime(1993, 1, 1, 0, 0),
-                        'host': 'eida.gfz-potsdam.de', 'end': None,
-                        'port': 18002}]})
+        self.assertEqual(results, expected_routing_ge)
         # 7 - GE.APE via webdc.eu:18002
         client = Client(host="webdc.eu", port=18002, user='test@obspy.org')
         results = client.get_routing('GE', 'APE', dt, dt + 1)
-        self.assertEqual(
-            results,
-            {'GE...': [{'priority': 1, 'start': UTCDateTime(1993, 1, 1, 0, 0),
-                        'host': 'eida.gfz-potsdam.de', 'end': None,
-                        'port': 18002}]})
+        self.assertEqual(results, expected_routing_ge)
         # 8 - unknown network 00 via webdc.eu:18002
         client = Client(host="webdc.eu", port=18002, user='test@obspy.org')
         results = client.get_routing('00', '', dt, dt + 1)
@@ -643,6 +626,11 @@ def test_issue_311(self):
         self.assertIn('paz', st[0].stats)
         self.assertIn('coordinates', st[0].stats)
 
+    # Seems the data used to test this issue has disappeared from the server.
+    # To implement the test again we would need some example test data with
+    # lots of gaps. It is most likely not worth the effort to reimplement this
+    # test.
+    @unittest.expectedFailure
     def test_issue_372(self):
         """
         Test case for issue #372.
diff --git a/obspy/clients/neic/tests/test_client.py b/obspy/clients/neic/tests/test_client.py
--- a/obspy/clients/neic/tests/test_client.py
+++ b/obspy/clients/neic/tests/test_client.py
@@ -86,8 +86,7 @@ def test_get_waveform_nscl(self):
                     "IUANMO BH.*",
                     "IUANMO BH[Z12].*",
                     "IUANMO BH[Z12]..",
-                    "IUANMO B.*",
-                    "..ANMO B.*"]
+                    "..ANMO BH.*"]
         for pattern in patterns:
             st2 = client.get_waveforms_nscl(pattern, t, duration)
             self.assertEqual(st, st2)