# 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
)
        dog.api_key = API_KEY
        dog.application_key = APP_KEY
        dog.swallow = False

    def test_tags(self):
        # post a metric to make sure the test host context exists
        hostname = 'test.tag.host'
        dog.metric('test.tag.metric', 1, host=hostname)

        dog.all_tags()

        dog.detach_tags(hostname)
        assert len(dog.host_tags(hostname)) == 0

        dog.add_tags(hostname, ['test.tag.1', 'test.tag.2'], source='datadog')
        new_tags = dog.host_tags(hostname)
        assert len(new_tags) == 2
        assert 'test.tag.1' in new_tags
        assert 'test.tag.2' in new_tags

        dog.add_tags(hostname, ['test.tag.3'], source='datadog')
        new_tags = dog.host_tags(hostname)
        assert len(new_tags) == 3
        assert 'test.tag.1' in new_tags
        assert 'test.tag.2' in new_tags
        assert 'test.tag.3' in new_tags

        dog.change_tags(hostname, ['test.tag.4'], source='datadog')
        new_tags = dog.host_tags(hostname)
        assert len(new_tags) == 1

# 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
)

        dog.api_key = API_KEY
        dog.application_key = APP_KEY
        dog.swallow = False

    def test_tags(self):
        # post a metric to make sure the test host context exists
        hostname = 'test.tag.host'
        dog.metric('test.tag.metric', 1, host=hostname)

        dog.all_tags()

        dog.detach_tags(hostname)
        assert len(dog.host_tags(hostname)) == 0

        dog.add_tags(hostname, ['test.tag.1', 'test.tag.2'], source='datadog')
        new_tags = dog.host_tags(hostname)
        assert len(new_tags) == 2
        assert 'test.tag.1' in new_tags
        assert 'test.tag.2' in new_tags

        dog.add_tags(hostname, ['test.tag.3'], source='datadog')
        new_tags = dog.host_tags(hostname)
        assert len(new_tags) == 3
        assert 'test.tag.1' in new_tags
        assert 'test.tag.2' in new_tags
        assert 'test.tag.3' in new_tags

        dog.change_tags(hostname, ['test.tag.4'], source='datadog')
        new_tags = dog.host_tags(hostname)
        assert len(new_tags) == 1

        assert 'test.tag.4' in new_tags