'Test aggregation: count'

def testAggregateCount(self):

    period = self.period
    assertEqual = self.assertEqual
    totals = period.aggregate(S3TimeSeriesFact('count', 'base'))
    expected_rows = {'A': [4], 'B': [4], 'C': [4]}
    rows = period.rows
    assertEqual(set(rows.keys()), set(expected_rows.keys()))
    for (k, v) in rows.items():
        assertEqual(v, expected_rows.get(k), msg=('Row    %s:    %s    !=    %s' % (k, v, expected_rows.get(k))))
    expected_cols = {1: [4], 2: [5], 3: [3]}
    cols = period.cols
    assertEqual(set(cols.keys()), set(expected_cols.keys()))
    for (k, v) in cols.items():
        assertEqual(v, expected_cols.get(k), msg=('Column    %s:    %s    !=    %s' % (k, v, expected_cols.get(k))))
    expected_matrix = {('A', 1): [2], ('A', 2): [2], ('B', 2): [2], ('B', 3): [2], ('C', 1): [2], ('C', 2): [1], ('C', 3): [1]}
    matrix = period.matrix
    assertEqual(set(matrix.keys()), set(expected_matrix.keys()))
    for (k, v) in matrix.items():
        assertEqual(v, expected_matrix.get(k), msg=('Cell    %s:    %s    !=    %s' % (k, v, expected_matrix.get(k))))
    expected_totals = [12]
    assertEqual(period.totals, expected_totals)
    assertEqual(totals, expected_totals)
