@@ 11,6 11,7 @@ from sqlalchemy import create_engine
from tshistory.schema import tsschema
from tshistory.tsio import timeseries
from tshistory import api as tsapi
+from tshistory.testutil import with_tester
from tshistory_rest import app, util
from tshistory_client import api
@@ 78,22 79,6 @@ class WebTester(webtest.TestApp):
expect_errors=expect_errors)
-def read_request_bridge(client, request):
- resp = client.get(request.url,
- params=request.body,
- headers=request.headers)
- return (resp.status_code, resp.headers, resp.body)
-
-
-def write_request_bridge(method):
- def bridge(request):
- resp = method(request.url,
- params=request.body,
- headers=request.headers)
- return (resp.status_code, resp.headers, resp.body)
- return bridge
-
-
URI = 'http://test-uri'
@pytest.fixture(scope='session')
@@ 110,134 95,5 @@ def client(engine):
)
)
with responses.RequestsMock(assert_all_requests_are_fired=False) as resp:
- resp.add_callback(
- responses.GET, 'http://test-uri/series/state',
- callback=partial(read_request_bridge, wsgitester)
- )
-
- resp.add_callback(
- responses.PUT, 'http://test-uri/series/state',
- callback=write_request_bridge(wsgitester.put)
- )
-
- resp.add_callback(
- responses.GET, 'http://test-uri/series/supervision',
- callback=partial(read_request_bridge, wsgitester)
- )
-
- resp.add_callback(
- responses.DELETE, 'http://test-uri/series/state',
- callback=write_request_bridge(wsgitester.delete)
- )
-
- resp.add_callback(
- responses.PUT, 'http://test-uri/series/strip',
- callback=write_request_bridge(wsgitester.put)
- )
-
- resp.add_callback(
- responses.GET, 'http://test-uri/series/insertion_dates',
- callback=partial(read_request_bridge, wsgitester)
- )
-
- resp.add_callback(
- responses.GET, 'http://test-uri/series/staircase',
- callback=partial(read_request_bridge, wsgitester)
- )
-
- resp.add_callback(
- responses.GET, 'http://test-uri/series/history',
- callback=partial(read_request_bridge, wsgitester)
- )
-
- resp.add_callback(
- responses.GET, 'http://test-uri/series/catalog',
- callback=partial(read_request_bridge, wsgitester)
- )
-
- resp.add_callback(
- responses.PATCH, 'http://test-uri/series/state',
- callback=write_request_bridge(wsgitester.patch)
- )
-
- resp.add_callback(
- responses.GET, 'http://test-uri/series/metadata',
- callback=partial(read_request_bridge, wsgitester)
- )
-
- resp.add_callback(
- responses.PUT, 'http://test-uri/series/metadata',
- callback=write_request_bridge(wsgitester.put)
- )
-
- resp.add_callback(
- responses.GET, 'http://test-uri/series/log',
- callback=partial(read_request_bridge, wsgitester)
- )
-
- resp.add_callback(
- responses.GET, 'http://test-uri/series/formula',
- callback=partial(read_request_bridge, wsgitester)
- )
-
- resp.add_callback(
- responses.PATCH, 'http://test-uri/series/formula',
- callback=write_request_bridge(wsgitester.patch)
- )
-
- resp.add_callback(
- responses.GET, 'http://test-uri/series/formula_components',
- callback=partial(read_request_bridge, wsgitester)
- )
-
- resp.add_callback(
- responses.GET, 'http://test-uri/group/state',
- callback=partial(read_request_bridge, wsgitester)
- )
-
- resp.add_callback(
- responses.PATCH, 'http://test-uri/group/state',
- callback=write_request_bridge(wsgitester.patch)
- )
-
- resp.add_callback(
- responses.DELETE, 'http://test-uri/group/state',
- callback=write_request_bridge(wsgitester.delete)
- )
-
- resp.add_callback(
- responses.GET, 'http://test-uri/group/metadata',
- callback=partial(read_request_bridge, wsgitester)
- )
-
- resp.add_callback(
- responses.PUT, 'http://test-uri/group/metadata',
- callback=write_request_bridge(wsgitester.put)
- )
-
- resp.add_callback(
- responses.GET, 'http://test-uri/group/catalog',
- callback=partial(read_request_bridge, wsgitester)
- )
-
- resp.add_callback(
- responses.GET, 'http://test-uri/group/formula',
- callback=partial(read_request_bridge, wsgitester)
- )
-
- resp.add_callback(
- responses.PUT, 'http://test-uri/group/formula',
- callback=write_request_bridge(wsgitester.put)
- )
-
- resp.add_callback(
- responses.GET, 'http://test-uri/group/boundformula',
- callback=partial(read_request_bridge, wsgitester)
- )
-
- resp.add_callback(
- responses.PUT, 'http://test-uri/group/boundformula',
- callback=write_request_bridge(wsgitester.put)
- )
-
+ with_tester(URI, resp, wsgitester)
yield api.Client(URI)