-
Notifications
You must be signed in to change notification settings - Fork 529
/
test_client.py
62 lines (50 loc) · 1.91 KB
/
test_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# -*- coding: utf-8 -*-
"""
The obspy.fdsn.client test suite.
"""
from obspy.fdsn import Client
from obspy.fdsn.client import build_url
import os
import unittest
class ClientTestCase(unittest.TestCase):
"""
Test cases for obspy.fdsn.client.Client.
"""
def setUp(self):
# directory where the test files are located
self.path = os.path.dirname(__file__)
def test_url_building(self):
"""
Tests the build_url() functions.
"""
# Application WADL
self.assertEqual(
build_url("http://service.iris.edu", 1, "dataselect",
"application.wadl"),
"http://service.iris.edu/fdsnws/dataselect/1/application.wadl")
self.assertEqual(
build_url("http://service.iris.edu", 1, "event",
"application.wadl"),
"http://service.iris.edu/fdsnws/event/1/application.wadl")
self.assertEqual(
build_url("http://service.iris.edu", 1, "station",
"application.wadl"),
"http://service.iris.edu/fdsnws/station/1/application.wadl")
# Some parameters. Only one is tested because the order is random if
# more than one is given.
self.assertEqual(
build_url("http://service.iris.edu", 1, "dataselect",
"query", {"network": "BW"}),
"http://service.iris.edu/fdsnws/dataselect/1/query?network=BW")
# A wrong resource_type raises a ValueError
self.assertRaises(ValueError, build_url, "http://service.iris.edu", 1,
"obspy", "query")
def test_service_discovery_iris(self):
"""
Tests the automatic discovery of services with the IRIS endpoint.
"""
c = Client(base_url="IRIS")
def suite():
return unittest.makeSuite(ClientTestCase, 'test')
if __name__ == '__main__':
unittest.main(defaultTest='suite')