def test_AggregateKeyPlugin():
    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 = plugin(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])
Generate the version string to use
dataset/ETHPy150Open alphagov/performanceplatform-collector/tests/performanceplatform/collector/ga/plugins/test_aggregate.py/test_AggregateKeyPlugin--crossover with--dataset/ETHPy150Open jakev/dtf/src/dtf/core/cmds/init.py/init.generate_version_string