'Test aggregation'

def testAggregate(self):

    assertIn = self.assertIn
    assertEqual = self.assertEqual
    items = [{'name': 'Item1', 'type': 'A', 'value': 2.6}, {'name': 'Item2', 'type': 'C', 'value': 4.9}, {'name': 'Item3', 'type': 'D', 'value': 7.2}, {'name': 'Item4', 'type': 'B', 'value': 1.5}, {'name': 'Item5', 'type': 'A', 'value': 9.4}, {'name': 'Item6', 'type': 'D', 'value': 6.1}, {'name': 'Item7', 'type': 'E', 'value': 3.5}]
    results = {'A': 12.0, 'B': 1.5, 'C': 4.9, 'D': 13.3, 'E': 3.5}
    gi = S3GroupedItems(items, groupby='type')
    aggregate = gi.aggregate('sum', 'value')
    assertEqual(aggregate.result, 35.2)
    for group in gi.groups:
        t = group['type']
        assertIn(('sum', 'value'), group._aggregates)
        assertEqual(group[('sum', 'value')], results[t])
