|
|
@@ -5,7 +5,7 @@ import nilmdb.client |
|
|
|
|
|
|
|
from nilmdb.utils.printf import * |
|
|
|
from nilmdb.utils import timestamper |
|
|
|
from nilmdb.client import ClientError, ServerError |
|
|
|
from nilmdb.client import ClientError, ServerError, Error |
|
|
|
from nilmdb.utils.sort import sort_human |
|
|
|
import datetime_tz |
|
|
|
|
|
|
@@ -79,6 +79,27 @@ class TestClient(object): |
|
|
|
# Bad URLs should give 404, not 500 |
|
|
|
with assert_raises(ClientError): |
|
|
|
client.http.get("/stream/create") |
|
|
|
|
|
|
|
# Test error handling |
|
|
|
url = testurl |
|
|
|
args = { "url": url, |
|
|
|
"status": "400", |
|
|
|
"message": "Something went wrong", |
|
|
|
"traceback": None } |
|
|
|
with assert_raises(ClientError): |
|
|
|
client.http._handle_error(url, 400, json.dumps(args)) |
|
|
|
with assert_raises(ClientError): |
|
|
|
client.http._handle_error(url, 400, "this is not JSON.. {") |
|
|
|
args["status"] = "500" |
|
|
|
with assert_raises(ServerError): |
|
|
|
client.http._handle_error(url, 500, json.dumps(args)) |
|
|
|
args["message"] = None |
|
|
|
with assert_raises(ServerError): |
|
|
|
client.http._handle_error(url, 500, json.dumps(args)) |
|
|
|
args["status"] = "600" |
|
|
|
with assert_raises(Error): |
|
|
|
client.http._handle_error(url, 600, json.dumps(args)) |
|
|
|
|
|
|
|
client.close() |
|
|
|
|
|
|
|
def test_client_02_createlist(self): |
|
|
@@ -212,7 +233,7 @@ class TestClient(object): |
|
|
|
data = timestamper.TimestamperRate(testfile, start, 120) |
|
|
|
with assert_raises(ClientError) as e: |
|
|
|
result = client.stream_insert("/newton/no-such-path", data) |
|
|
|
in_("404 Not Found", str(e.exception)) |
|
|
|
in_("404 Not Found", repr(e.exception)) |
|
|
|
|
|
|
|
# Now try reversed timestamps |
|
|
|
data = timestamper.TimestamperRate(testfile, start, 120) |
|
|
|