@attr('snapshot')
    def test_graph_snapshot(self):
        metric_query = "system.load.1{*}"
        event_query = "*"
        end = int(time.time())
        start = end - 60 * 60  # go back 1 hour

        # Test without an event query
        snap = dog.graph_snapshot(metric_query, start, end)
        ok('snapshot_url' in snap, msg=snap)
        ok('metric_query' in snap, msg=snap)
        ok('event_query' not in snap, msg=snap)
        eq(snap['metric_query'], metric_query)
        snapshot_url = snap['snapshot_url']
        while dog.snapshot_status(snapshot_url) != 200:
            time.sleep(2)
        if 'localhost' in dog.api_host:
            snapshot_url = 'http://%s%s' % (dog.api_host, snapshot_url)
        assert_snap_not_blank(snapshot_url)
        assert_snap_has_no_events(snapshot_url)

        # Test with an event query
        snap = dog.graph_snapshot(metric_query, start, end,
                                  event_query=event_query)
        ok('snapshot_url' in snap, msg=snap)
        ok('metric_query' in snap, msg=snap)
        ok('event_query' in snap, msg=snap)
        eq(snap['metric_query'], metric_query)
        eq(snap['event_query'], event_query)
        snapshot_url = snap['snapshot_url']
        while dog.snapshot_status(snapshot_url) != 200:
            time.sleep(2)
        if 'localhost' in dog.api_host:
            snapshot_url = 'http://%s%s' % (dog.api_host, snapshot_url)
        assert_snap_not_blank(snapshot_url)

        # Test with a graph def
        graph_def = {
            "viz": "toplist",
            "requests": [{
                "q": "top(system.disk.free{*} by {device}, 10, 'mean', 'desc')",
                "style": {
                    "palette": "dog_classic"
                },
                "conditional_formats": [{
                    "palette": "red",
                    "comparator": ">",
                    "value": 50000000000
                }, {
                    "palette": "green",
                    "comparator": ">",
                    "value": 30000000000
                }]
            }]
        }
        graph_def = json.dumps(graph_def)
        snap = dog.graph_snapshot_from_def(graph_def, start, end)
        ok('snapshot_url' in snap, msg=snap)
        ok('graph_def' in snap, msg=snap)
        ok('metric_query' not in snap, msg=snap)
        ok(snap not in 'event_query', msg=snap)
        eq(snap['graph_def'], graph_def)
        snapshot_url = snap['snapshot_url']
        while dog.snapshot_status(snapshot_url) != 200:
            time.sleep(2)
        if 'localhost' in dog.api_host:
            snapshot_url = 'http://%s%s' % (dog.api_host, snapshot_url)
        assert_snap_not_blank(snapshot_url)
dataset/ETHPy150Open DataDog/dogapi/tests/integration/test_dog_http_api.py/TestDatadog.test_graph_snapshot/swapped operands of `not in`