

def test_AggregateKeyPlugin():
    '\n    test_AggregateKeyPlugin()\n\n    Test that the AggregateKey class behaves as a plugin correctly.\n    '
    from nose.tools import assert_equal
    doc1 = {
        'a': 2,
        'b': 2,
        'c': 2,
        'visits': 100,
        'rate': 0.25,
    }
    doc2 = {
        'a': 2,
        'b': 2,
        'c': 2,
        'visits': 100,
        'rate': 0.75,
    }
    docs = [doc1, doc2]
    plugin = AggregateKey(aggregate_count('visits'), aggregate_rate('rate', 'visits'))
    output_docs = expected_aggregate(docs)
    expected_aggregate = {
        'a': 2,
        'b': 2,
        'c': 2,
        'visits': 200,
        'rate': (((0.25 * 100) + (0.75 * 100)) / (100 + 100)),
    }
    assert_equal(output_docs, [expected_aggregate])

dataset/ETHPy150Open alphagov/performanceplatform-collector/tests/performanceplatform/collector/ga/plugins/test_aggregate.py test_AggregateKeyPlugin/VarMisuse@107/188 `plugin`->`expected_aggregate`