From 725c8428fed52f2bc54dee66701eaf024a5231c1 Mon Sep 17 00:00:00 2001 From: Isaac Sadaqah Date: Tue, 30 Sep 2014 16:30:49 -0400 Subject: [PATCH] Make snapshot path part of the url and improve tests --- src/dogapi/http/snapshot.py | 9 +++++---- tests/util/snapshot_test_utils.py | 7 +++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/dogapi/http/snapshot.py b/src/dogapi/http/snapshot.py index df3feeb..994c264 100644 --- a/src/dogapi/http/snapshot.py +++ b/src/dogapi/http/snapshot.py @@ -74,8 +74,9 @@ def snapshot_status(self, snapshot_url): >> time.sleep(1) >> img = urllib.urlopen(snapshot_url) """ - snap_path = urlparse(snapshot_url).path.split('/snapshot/view/')[1] + snap_path = urlparse(snapshot_url).path + snap_path = snap_path.split('/snapshot/view/')[1].split('.png')[0] + snapshot_status_url = '/graph/snapshot_status/{0}'.format(snap_path) get_status_code = lambda x: int(x['status_code']) - return self.http_request('GET', '/graph/snapshot_status', - response_formatter=get_status_code, - snap_path=snap_path) \ No newline at end of file + return self.http_request('GET', snapshot_status_url, + response_formatter=get_status_code) \ No newline at end of file diff --git a/tests/util/snapshot_test_utils.py b/tests/util/snapshot_test_utils.py index 3274217..2479498 100644 --- a/tests/util/snapshot_test_utils.py +++ b/tests/util/snapshot_test_utils.py @@ -21,7 +21,10 @@ def assert_snap_not_blank(snapshot_url): nt.ok_(pixels is not None and isinstance(pixels, list) and len(set(pixels)) > 2, - msg="Invalid or blank snapshot") + msg="Invalid or blank snapshot: {0}".format(snapshot_url)) + for pixel in set(pixels): + nt.ok_(isinstance(pixel, tuple), + msg="Invalid snapshot: {0}".format(snapshot_url)) def assert_snap_has_no_events(snapshot_url): @@ -30,4 +33,4 @@ def assert_snap_has_no_events(snapshot_url): for color in set(pixels): r, g, b, a = color # red, green, blue, alpha nt.ok_(r != 255 or g != 230 and b != 230, - msg="Snapshot should not have events") \ No newline at end of file + msg="Snapshot should not have events: {0}".format(snapshot_url)) \ No newline at end of file