Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Make snapshot path part of the url and improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacdd committed Sep 30, 2014
1 parent d7e5eb8 commit 725c842
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/dogapi/http/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
return self.http_request('GET', snapshot_status_url,
response_formatter=get_status_code)
7 changes: 5 additions & 2 deletions tests/util/snapshot_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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")
msg="Snapshot should not have events: {0}".format(snapshot_url))

0 comments on commit 725c842

Please sign in to comment.