#NEWLINE# def test_min_by_multiple( self ) : #NEWLINE# #INDENT# scheduler = TestScheduler ( ) #NEWLINE# msgs = [ on_next ( 150 , { #NEWLINE# #INDENT# 'key' : 1 , #NEWLINE# 'value' : 'z' , #NEWLINE# #UNINDENT# } ) , on_next ( 210 , { #NEWLINE# #INDENT# 'key' : 3 , #NEWLINE# 'value' : 'b' , #NEWLINE# #UNINDENT# } ) , on_next ( 215 , { #NEWLINE# #INDENT# 'key' : 2 , #NEWLINE# 'value' : 'd' , #NEWLINE# #UNINDENT# } ) , on_next ( 220 , { #NEWLINE# #INDENT# 'key' : 3 , #NEWLINE# 'value' : 'c' , #NEWLINE# #UNINDENT# } ) , on_next ( 225 , { #NEWLINE# #INDENT# 'key' : 2 , #NEWLINE# 'value' : 'y' , #NEWLINE# #UNINDENT# } ) , on_next ( 230 , { #NEWLINE# #INDENT# 'key' : 4 , #NEWLINE# 'value' : 'a' , #NEWLINE# #UNINDENT# } ) , on_next ( 235 , { #NEWLINE# #INDENT# 'key' : 4 , #NEWLINE# 'value' : 'r' , #NEWLINE# #UNINDENT# } ) , on_completed ( 250 ) ] #NEWLINE# xs = scheduler . create_hot_observable ( msgs ) #NEWLINE# def create( ) : #NEWLINE# #INDENT# return xs . min_by ( ( lambda x : x [ 'key' ] ) ) #NEWLINE# #UNINDENT# res = scheduler . start ( create = xs ) . messages #NEWLINE# self . assertEqual ( 2 , len ( res ) ) #NEWLINE# assert ( res [ 0 ] . value . kind == 'N' ) #NEWLINE# self . assertEqual ( 2 , len ( res [ 0 ] . value . value ) ) #NEWLINE# self . assertEqual ( 2 , res [ 0 ] . value . value [ 0 ] [ 'key' ] ) #NEWLINE# self . assertEqual ( 'd' , res [ 0 ] . value . value [ 0 ] [ 'value' ] ) #NEWLINE# self . assertEqual ( 2 , res [ 0 ] . value . value [ 1 ] [ 'key' ] ) #NEWLINE# self . assertEqual ( 'y' , res [ 0 ] . value . value [ 1 ] [ 'value' ] ) #NEWLINE# assert ( ( res [ 1 ] . value . kind == 'C' ) and ( res [ 1 ] . time == 250 ) )