@@ -0,0 +1,2331 @@
+from query import Query%0Afrom app import build_graphs_from_targets%0Afrom target import Target%0A%0A%0Adef test_nontrivial_implicit_aggregation():%0A    # we ultimately want 1 graph with 1 line for each server,%0A    # irrespective of the values of the other tags (n1 and n2)%0A    # and even whether or not the metrics have those tags at all.%0A    query = Query(%22%22)%0A    query%5B'group_by'%5D = %7B%7D%0A    query%5B'sum_by'%5D = %7B'n1': %5B''%5D, 'n2': %5B''%5D%7D%0A%0A    targets = %7B%0A        # web1 : one with and without n2%0A        'web1.a.a': %7B%0A            'id': 'web1.a.a',%0A            'tags': %7B%0A                'server': 'web1',%0A                'n1': 'a',%0A                'n2': 'a'%0A            %7D%0A        %7D,%0A        'web1.a': %7B%0A            'id': 'web1.a',%0A            'tags': %7B%0A                'server': 'web1',%0A                'n1': 'a',%0A            %7D%0A        %7D,%0A        # web 2: 2 different values of n2%0A        'web2.a.a': %7B%0A            'id': 'web2.a.a',%0A            'tags': %7B%0A                'server': 'web2',%0A                'n1': 'a',%0A                'n2': 'a'%0A            %7D%0A        %7D,%0A        'web2.a.b': %7B%0A            'id': 'web2.a.b',%0A            'tags': %7B%0A                'server': 'web2',%0A                'n1': 'a',%0A                'n2': 'b'%0A            %7D%0A        %7D,%0A        # web3: with and without n2, diff value for n1%0A        'web3.a.a': %7B%0A            'id': 'web3.a.a',%0A            'tags': %7B%0A                'server': 'web3',%0A                'n1': 'a',%0A                'n2': 'a'%0A            %7D%0A        %7D,%0A        'web3.b': %7B%0A            'id': 'web3.b',%0A            'tags': %7B%0A                'server': 'web3',%0A                'n1': 'b'%0A            %7D%0A        %7D%0A    %7D%0A    from pprint import pprint%0A    for (k, v) in targets.items():%0A        v = Target(v)%0A        v.get_graph_info(group_by=%7B%7D)%0A        targets%5Bk%5D = v%0A    graphs, _query = build_graphs_from_targets(targets, query)%0A    # TODO: there should be only 1 graph, containing 3 lines, with each 2 targets per server%0A    # i.e. something like this:%0A    expected = %7B%0A        'targets': %7B%0A            %7B'id': %5B'web1.a.a', 'web1.a'%5D%7D,%0A            %7B'id': %5B'web2.a.a', 'web2.a.b'%5D%7D,%0A            %7B'id': %5B'web3.a.a', 'web3.b'%5D%7D%0A        %7D%0A    %7D%0A%0A    print %22Graphs:%22%0A    for (k, v) in graphs.items():%0A        print %22graph key%22%0A        pprint(k)%0A        print %22val:%22%0A        pprint(v)%0A    assert expected == graphs%0A

add failing test case for #81