# Path: tests/util/snapshot_test_utils.py
# def assert_snap_not_blank(snapshot_url):
#     """ Asserts snapshot is not blank"""
#     pixels = read_image_as_raster(snapshot_url)
#     nt.ok_(pixels is not None
#            and isinstance(pixels, list)
#            and len(set(pixels)) > 2,
#            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):
#     """ Asserts snapshot has no events"""
#     pixels = read_image_as_raster(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: {0}".format(snapshot_url))


import datetime
import os
import time
import unittest
import nose.tools as nt
import simplejson as json
import dogapi
from nose.plugins.attrib import attr
from nose.tools import assert_equal as eq
from nose.tools import assert_true as ok
from dogapi.exceptions import *
from tests.util.snapshot_test_utils import (
    assert_snap_not_blank, assert_snap_has_no_events
)

        self.assertEquals(now_event['text'], now_message)
        self.assertEquals(before_event['text'], before_message)

        event_id = dog.event_with_response('test host and device',
                                           'test host and device',
                                           host='test.host',
                                           device_name='test.device')
        time.sleep(wait_time)
        event = dog.get_event(event_id)

        self.assertEquals(event['host'], 'test.host')
        self.assertEquals(event['device_name'], 'test.device')

        event_id = dog.event_with_response('test event tags',
                                           'test event tags',
                                           tags=['test-tag-1', 'test-tag-2'])
        time.sleep(wait_time)
        event = dog.get_event(event_id)

        assert 'test-tag-1' in event['tags']
        assert 'test-tag-2' in event['tags']

    def test_aggregate_events(self):
        now_ts = int(time.time())
        agg_key = 'aggregate_me ' + str(now_ts)
        msg_1 = 'aggregate 1'
        msg_2 = 'aggregate 2'

        # send two events that should aggregate

# Path: tests/util/snapshot_test_utils.py
# def assert_snap_not_blank(snapshot_url):
#     """ Asserts snapshot is not blank"""
#     pixels = read_image_as_raster(snapshot_url)
#     nt.ok_(pixels is not None
#            and isinstance(pixels, list)
#            and len(set(pixels)) > 2,
#            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):
#     """ Asserts snapshot has no events"""
#     pixels = read_image_as_raster(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: {0}".format(snapshot_url))


# Path: tests/integration/test_dog_http_api.py
import datetime
import os
import time
import unittest
import nose.tools as nt
import simplejson as json
import dogapi
from nose.plugins.attrib import attr
from nose.tools import assert_equal as eq
from nose.tools import assert_true as ok
from dogapi.exceptions import *
from tests.util.snapshot_test_utils import (
    assert_snap_not_blank, assert_snap_has_no_events
)


        self.assertEquals(now_event['text'], now_message)
        self.assertEquals(before_event['text'], before_message)

        event_id = dog.event_with_response('test host and device',
                                           'test host and device',
                                           host='test.host',
                                           device_name='test.device')
        time.sleep(wait_time)
        event = dog.get_event(event_id)

        self.assertEquals(event['host'], 'test.host')
        self.assertEquals(event['device_name'], 'test.device')

        event_id = dog.event_with_response('test event tags',
                                           'test event tags',
                                           tags=['test-tag-1', 'test-tag-2'])
        time.sleep(wait_time)
        event = dog.get_event(event_id)

        assert 'test-tag-1' in event['tags']
        assert 'test-tag-2' in event['tags']

    def test_aggregate_events(self):
        now_ts = int(time.time())
        agg_key = 'aggregate_me ' + str(now_ts)
        msg_1 = 'aggregate 1'
        msg_2 = 'aggregate 2'

        # send two events that should aggregate

        event1_id = dog.event_with_response(msg_1, msg_1, aggregation_key=agg_key)