#NEWLINE# def test_reserve_experiment_reserved( self ) : #NEWLINE# #INDENT# 'Reserve and confirm the reservation' #NEWLINE# ( status , reservation1_id ) = self . coordinator . reserve_experiment ( ExperimentId ( 'exp1' , 'cat1' ) , DEFAULT_TIME , DEFAULT_PRIORITY , True , DEFAULT_INITIAL_DATA , DEFAULT_REQUEST_INFO , DEFAULT_CONSUMER_DATA ) #NEWLINE# now = datetime . datetime . fromtimestamp ( int ( time . time ( ) ) ) #NEWLINE# expected_status = WSS . WaitingConfirmationQueueStatus ( reservation1_id , DEFAULT_URL ) #NEWLINE# self . assertEquals ( expected_status , status ) #NEWLINE# self . assertEquals ( 1 , len ( self . coordinator . confirmer . uses_confirm ) ) #NEWLINE# laboratory_coord_address = 'lab1:inst@machine' #NEWLINE# experiment_instance_id = ExperimentInstanceId ( 'inst1' , 'exp1' , 'cat1' ) #NEWLINE# self . assertEquals ( experiment_instance_id , self . coordinator . confirmer . uses_confirm [ 0 ] [ 0 ] ) #NEWLINE# self . assertEquals ( laboratory_coord_address , self . coordinator . confirmer . uses_confirm [ 0 ] [ 0 ] ) #NEWLINE# self . assertEquals ( experiment_instance_id , self . coordinator . confirmer . uses_confirm [ 0 ] [ 2 ] ) #NEWLINE# self . coordinator . confirm_experiment ( coord_addr ( 'expser:inst@mach' ) , ExperimentId ( 'exp1' , 'cat1' ) , reservation1_id , 'lab:server@mach' , SessionId . SessionId ( 'mysessionid' ) , '{}' , now , now , 'res_type' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# status = self . coordinator . get_reservation_status ( reservation1_id ) #NEWLINE# expected_status = WSS . LocalReservedStatus ( reservation1_id , coord_addr ( laboratory_coord_address ) , SessionId . SessionId ( 'mysessionid' ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , DEFAULT_TIME , '{}' , now , now , True , DEFAULT_TIME , 'http://www.weblab.deusto.es/weblab/client/foo' ) #NEWLINE# self . assertTrue ( ( 'Unexpected status due to timestamp_before: %s; expected something like %s' % ( status , expected_status ) ) , ( ( status . timestamp_before >= now ) and ( status . timestamp_before <= ( now + datetime . timedelta ( seconds = 10 ) ) ) ) ) #NEWLINE# self . assertTrue ( ( 'Unexpected status due to timestamp_after: %s; expected something like %s' % ( status , expected_status ) ) , ( ( status . timestamp_after >= now ) and ( status . timestamp_after <= ( now + datetime . timedelta ( seconds = 10 ) ) ) ) ) #NEWLINE# status . timestamp_before = now #NEWLINE# status . timestamp_after = now #NEWLINE# self . assertEquals ( expected_status , status )