<s> """<STR_LIT>""" <EOL> import unittest <EOL> from cube . expression import CompoundMetricExpression <EOL> from cube . expression import EventExpression <EOL> from cube . expression import Max <EOL> from cube . expression import MetricExpression <EOL> from cube . expression import Min <EOL> from cube . expression import Sum <EOL> class TestCompoundMetricExpressions ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . e = EventExpression ( '<STR_LIT:test>' , '<STR_LIT>' ) <EOL> self . sum = Sum ( self . e ) <EOL> self . max = Max ( self . e ) <EOL> self . min = Min ( self . e ) <EOL> def test_addition ( self ) : <EOL> self . assertEqual ( "<STR_LIT:%s>" % ( self . sum + self . min ) , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( "<STR_LIT:%s>" % ( self . sum + self . min + self . max ) , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( "<STR_LIT:%s>" % <EOL> ( ( self . sum + self . min ) + ( self . max + self . max ) ) , <EOL> "<STR_LIT>" "<STR_LIT>" ) <EOL> def test_subtraction ( self ) : <EOL> self . assertEqual ( "<STR_LIT:%s>" % ( self . sum - self . min - self . max ) , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( "<STR_LIT:%s>" % <EOL> ( ( self . sum - self . min ) + ( self . max - self . sum ) ) , <EOL> "<STR_LIT>" "<STR_LIT>" ) <EOL> def test_multiplication ( self ) : <EOL> self . assertEqual ( "<STR_LIT:%s>" % ( self . sum - self . min * self . max ) , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( "<STR_LIT:%s>" % <EOL> ( ( self . max - self . min ) * ( self . sum + self . min ) ) , <EOL> "<STR_LIT>" "<STR_LIT>" ) <EOL> self . assertEqual ( "<STR_LIT:%s>" % <EOL> ( self . max - self . min * self . sum + self . min ) , <EOL> "<STR_LIT>" "<STR_LIT>" ) <EOL> def test_division ( self ) : <EOL> self . assertEqual ( "<STR_LIT:%s>" % ( self . max / self . sum * self . min ) , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( "<STR_LIT:%s>" % <EOL> ( ( self . min / self . sum ) / ( self . min + self . max ) ) , <EOL> "<STR_LIT>" "<STR_LIT>" ) <EOL> self . assertEqual ( "<STR_LIT:%s>" % <EOL> ( self . min / self . sum * self . max + self . min - self . max ) , <EOL> "<STR_LIT>" "<STR_LIT>" ) <EOL> def test_types ( self ) : <EOL> self . assertTrue ( isinstance ( self . min , MetricExpression ) ) <EOL> self . assertTrue ( isinstance ( self . max , MetricExpression ) ) <EOL> self . assertTrue ( isinstance ( self . sum + self . sum , <EOL> CompoundMetricExpression ) ) <EOL> self . assertTrue ( isinstance ( self . sum + self . min , <EOL> CompoundMetricExpression ) ) <EOL> self . assertTrue ( isinstance ( self . max + self . min , <EOL> CompoundMetricExpression ) ) <EOL> m1 = self . sum <EOL> m2 = self . min <EOL> self . assertTrue ( isinstance ( m1 + m2 , CompoundMetricExpression ) ) <EOL> self . assertTrue ( isinstance ( m1 - m2 , CompoundMetricExpression ) ) <EOL> self . assertTrue ( isinstance ( m1 * m2 , CompoundMetricExpression ) ) <EOL> self . assertTrue ( isinstance ( m1 . __div__ ( m2 ) , CompoundMetricExpression ) ) <EOL> self . assertTrue ( isinstance ( <EOL> m1 . __truediv__ ( m2 ) , CompoundMetricExpression ) ) <EOL> def test_filters ( self ) : <EOL> e1 = EventExpression ( '<STR_LIT>' , '<STR_LIT>' ) . eq ( '<STR_LIT:path>' , '<STR_LIT:/>' ) <EOL> e2 = e1 . gt ( '<STR_LIT>' , <NUM_LIT> ) <EOL> self . assertEqual ( "<STR_LIT:%s>" % ( Sum ( e1 ) - Min ( e2 ) ) , <EOL> "<STR_LIT>" "<STR_LIT>" "<STR_LIT>" ) </s>
