<s> import ddt <EOL> import jsonschema <EOL> from rally . plugins . common . sla import iteration_time <EOL> from tests . unit import test <EOL> @ ddt . ddt <EOL> class IterationTimeTestCase ( test . TestCase ) : <EOL> def test_config_schema ( self ) : <EOL> properties = { <EOL> "<STR_LIT>" : <NUM_LIT:0> <EOL> } <EOL> self . assertRaises ( jsonschema . ValidationError , <EOL> iteration_time . IterationTime . validate , properties ) <EOL> def test_result ( self ) : <EOL> sla1 = iteration_time . IterationTime ( <NUM_LIT> ) <EOL> sla2 = iteration_time . IterationTime ( <NUM_LIT> ) <EOL> for sla in [ sla1 , sla2 ] : <EOL> sla . add_iteration ( { "<STR_LIT>" : <NUM_LIT> } ) <EOL> sla . add_iteration ( { "<STR_LIT>" : <NUM_LIT> } ) <EOL> self . assertTrue ( sla1 . result ( ) [ "<STR_LIT:success>" ] ) <EOL> self . assertFalse ( sla2 . result ( ) [ "<STR_LIT:success>" ] ) <EOL> self . assertEqual ( "<STR_LIT>" , sla1 . status ( ) ) <EOL> self . assertEqual ( "<STR_LIT>" , sla2 . status ( ) ) <EOL> def test_result_no_iterations ( self ) : <EOL> sla = iteration_time . IterationTime ( <NUM_LIT> ) <EOL> self . assertTrue ( sla . result ( ) [ "<STR_LIT:success>" ] ) <EOL> def test_add_iteration ( self ) : <EOL> sla = iteration_time . IterationTime ( <NUM_LIT> ) <EOL> self . assertTrue ( sla . add_iteration ( { "<STR_LIT>" : <NUM_LIT> } ) ) <EOL> self . assertTrue ( sla . add_iteration ( { "<STR_LIT>" : <NUM_LIT> } ) ) <EOL> self . assertTrue ( sla . add_iteration ( { "<STR_LIT>" : <NUM_LIT> } ) ) <EOL> self . assertFalse ( sla . add_iteration ( { "<STR_LIT>" : <NUM_LIT> } ) ) <EOL> self . assertFalse ( sla . add_iteration ( { "<STR_LIT>" : <NUM_LIT> } ) ) <EOL> @ ddt . data ( [ [ <NUM_LIT:1.0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1.> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ] ) <EOL> def test_merge ( self , durations ) : <EOL> single_sla = iteration_time . IterationTime ( <NUM_LIT> ) <EOL> for dd in durations : <EOL> for d in dd : <EOL> single_sla . add_iteration ( { "<STR_LIT>" : d } ) <EOL> slas = [ iteration_time . IterationTime ( <NUM_LIT> ) for _ in durations ] <EOL> for idx , sla in enumerate ( slas ) : <EOL> for duration in durations [ idx ] : <EOL> sla . add_iteration ( { "<STR_LIT>" : duration } ) <EOL> merged_sla = slas [ <NUM_LIT:0> ] <EOL> for sla in slas [ <NUM_LIT:1> : ] : <EOL> merged_sla . merge ( sla ) <EOL> self . assertEqual ( single_sla . success , merged_sla . success ) <EOL> self . assertEqual ( single_sla . max_iteration_time , <EOL> merged_sla . max_iteration_time ) </s>
