|
|
@@ -227,7 +227,7 @@ class TestClient(object): |
|
|
|
client = nilmdb.Client(url = "http://localhost:12380/") |
|
|
|
|
|
|
|
for x in client.stream_extract("/newton/prep", 123, 123): |
|
|
|
raise Exception("shouldn't be any data for this request") |
|
|
|
raise AssertionError("shouldn't be any data for this request") |
|
|
|
|
|
|
|
with assert_raises(ClientError) as e: |
|
|
|
client.stream_remove("/newton/prep", 123, 120) |
|
|
@@ -281,28 +281,38 @@ class TestClient(object): |
|
|
|
in_("404 Not Found", str(e.exception)) |
|
|
|
in_("No such stream", str(e.exception)) |
|
|
|
|
|
|
|
def test_client_7_chunked(self): |
|
|
|
def test_client_7_headers(self): |
|
|
|
# Make sure that /stream/intervals and /stream/extract |
|
|
|
# properly return streaming, chunked response. Pokes around |
|
|
|
# in client.http internals a bit to look at the response |
|
|
|
# headers. |
|
|
|
# properly return streaming, chunked, text/plain response. |
|
|
|
# Pokes around in client.http internals a bit to look at the |
|
|
|
# response headers. |
|
|
|
|
|
|
|
client = nilmdb.Client(url = "http://localhost:12380/") |
|
|
|
http = client.http |
|
|
|
|
|
|
|
# Use a warning rather than returning a test failure, so that we can |
|
|
|
# still disable chunked responses for debugging. |
|
|
|
x = client.http.get("stream/intervals", { "path": "/newton/prep" }, |
|
|
|
|
|
|
|
# Intervals |
|
|
|
x = http.get("stream/intervals", { "path": "/newton/prep" }, |
|
|
|
retjson=False) |
|
|
|
lines_(x, 1) |
|
|
|
if "transfer-encoding: chunked" not in client.http._headers.lower(): |
|
|
|
if "Transfer-Encoding: chunked" not in http._headers: |
|
|
|
warnings.warn("Non-chunked HTTP response for /stream/intervals") |
|
|
|
if "Content-Type: text/plain;charset=utf-8" not in http._headers: |
|
|
|
raise AssertionError("/stream/intervals is not text/plain:\n" + |
|
|
|
http._headers) |
|
|
|
|
|
|
|
x = client.http.get("stream/extract", |
|
|
|
# Extract |
|
|
|
x = http.get("stream/extract", |
|
|
|
{ "path": "/newton/prep", |
|
|
|
"start": "123", |
|
|
|
"end": "123" }, retjson=False) |
|
|
|
if "transfer-encoding: chunked" not in client.http._headers.lower(): |
|
|
|
if "Transfer-Encoding: chunked" not in http._headers: |
|
|
|
warnings.warn("Non-chunked HTTP response for /stream/extract") |
|
|
|
if "Content-Type: text/plain;charset=utf-8" not in http._headers: |
|
|
|
raise AssertionError("/stream/extract is not text/plain:\n" + |
|
|
|
http._headers) |
|
|
|
|
|
|
|
def test_client_8_unicode(self): |
|
|
|
# Basic Unicode tests |
|
|
|