#NEWLINE# def testAggregateSum( self ) : #NEWLINE# #INDENT# ' Test aggregation: sum ' #NEWLINE# period = self . period #NEWLINE# assertEqual = self . assertEqual #NEWLINE# totals = period . aggregate ( S3TimeSeriesFact ( 'sum' , 'base' ) ) #NEWLINE# expected_rows = { #NEWLINE# #INDENT# 'A' : [ 180 ] , #NEWLINE# 'B' : [ 370 ] , #NEWLINE# 'C' : [ 810 ] , #NEWLINE# #UNINDENT# } #NEWLINE# rows = period . rows #NEWLINE# assertEqual ( set ( rows . keys ( ) ) , set ( expected_rows . keys ( ) ) ) #NEWLINE# for ( k , v ) in rows . items ( ) : #NEWLINE# #INDENT# assertEqual ( v , expected_rows . get ( k ) , msg = ( 'Row %s: %s != %s' % ( k , v , expected_rows . get ( k ) ) ) ) #NEWLINE# #UNINDENT# expected_cols = { #NEWLINE# #INDENT# 1 : [ 430 ] , #NEWLINE# 2 : [ 290 ] , #NEWLINE# 3 : [ 640 ] , #NEWLINE# #UNINDENT# } #NEWLINE# cols = period . cols #NEWLINE# assertEqual ( set ( cols . keys ( ) ) , set ( expected_cols . keys ( ) ) ) #NEWLINE# for ( k , v ) in cols . items ( ) : #NEWLINE# #INDENT# assertEqual ( v , expected_cols . get ( k ) , msg = ( 'Column %s: %s != %s' % ( k , v , expected_cols . get ( k ) ) ) ) #NEWLINE# #UNINDENT# expected_matrix = { #NEWLINE# #INDENT# ( 'A' , 1 ) : [ 80 ] , #NEWLINE# ( 'A' , 2 ) : [ 100 ] , #NEWLINE# ( 'B' , 2 ) : [ 130 ] , #NEWLINE# ( 'B' , 3 ) : [ 240 ] , #NEWLINE# ( 'C' , 1 ) : [ 350 ] , #NEWLINE# ( 'C' , 2 ) : [ 60 ] , #NEWLINE# ( 'C' , 3 ) : [ 400 ] , #NEWLINE# #UNINDENT# } #NEWLINE# matrix = period . matrix #NEWLINE# assertEqual ( set ( matrix . keys ( ) ) , set ( expected_matrix . keys ( ) ) ) #NEWLINE# for ( k , v ) in matrix . items ( ) : #NEWLINE# #INDENT# assertEqual ( v , expected_matrix . get ( k ) , msg = ( 'Cell %s: %s != %s' % ( k , v , expected_matrix . get ( k ) ) ) ) #NEWLINE# #UNINDENT# expected_totals = [ 1360 ] #NEWLINE# assertEqual ( period . totals , expected_totals ) #NEWLINE# assertEqual ( v , expected_totals )