#NEWLINE# def test_ball_missing_to_pf_and_drain_with_pf_switch( self ) : #NEWLINE# #INDENT# coil1 = self . machine . coils [ 'eject_coil1' ] #NEWLINE# coil2 = self . machine . coils [ 'eject_coil2' ] #NEWLINE# coil3 = self . machine . coils [ 'eject_coil3' ] #NEWLINE# trough = self . machine . ball_devices [ 'test_trough' ] #NEWLINE# launcher = self . machine . ball_devices [ 'test_launcher' ] #NEWLINE# target = self . machine . ball_devices [ 'test_target1' ] #NEWLINE# playfield = self . machine . ball_devices [ 'playfield' ] #NEWLINE# self . machine . events . add_handler ( 'balldevice_captured_from_playfield' , self . _captured_from_pf ) #NEWLINE# self . machine . events . add_handler ( 'balldevice_1_ball_missing' , self . _missing_ball ) #NEWLINE# self . machine . events . add_handler ( 'collecting_balls_complete' , self . _collecting_balls_complete_handler ) #NEWLINE# self . assertEquals ( None , self . machine . game ) #NEWLINE# self . _enter = 0 #NEWLINE# self . _captured = 0 #NEWLINE# self . _missing = 0 #NEWLINE# self . _collecting_balls_complete = 0 #NEWLINE# self . machine . ball_controller . num_balls_known = 2 #NEWLINE# self . machine . switch_controller . process_switch ( 's_ball_switch1' , 1 ) #NEWLINE# self . machine . switch_controller . process_switch ( 's_ball_switch2' , 1 ) #NEWLINE# self . advance_time_and_run ( 1 ) #NEWLINE# self . assertEquals ( 2 , self . _captured ) #NEWLINE# self . _captured = 0 #NEWLINE# self . assertEquals ( 0 , playfield . balls ) #NEWLINE# self . assertEquals ( 2 , self . machine . ball_controller . num_balls_known ) #NEWLINE# coil1 . pulse = MagicMock ( ) #NEWLINE# coil2 . pulse = MagicMock ( ) #NEWLINE# coil3 . pulse = MagicMock ( ) #NEWLINE# self . assertEquals ( 2 , trough . balls ) #NEWLINE# assert ( not coil1 . pulse . called ) #NEWLINE# assert ( not coil2 . pulse . called ) #NEWLINE# assert ( not coil3 . pulse . called ) #NEWLINE# self . machine . switch_controller . process_switch ( 's_start' , 1 ) #NEWLINE# self . advance_time_and_run ( 0.1 ) #NEWLINE# self . machine . switch_controller . process_switch ( 's_start' , 0 ) #NEWLINE# self . advance_time_and_run ( 1 ) #NEWLINE# self . assertNotEquals ( None , self . machine . game ) #NEWLINE# coil1 . pulse . assert_called_once_with ( ) #NEWLINE# assert ( not coil2 . pulse . called ) #NEWLINE# assert ( not coil3 . pulse . called ) #NEWLINE# self . machine . switch_controller . process_switch ( 's_ball_switch1' , 0 ) #NEWLINE# self . advance_time_and_run ( 1 ) #NEWLINE# self . assertEquals ( 1 , trough . balls ) #NEWLINE# self . machine . switch_controller . process_switch ( 's_ball_switch_launcher' , 1 ) #NEWLINE# self . advance_time_and_run ( 1 ) #NEWLINE# self . assertEquals ( 1 , launcher . balls ) #NEWLINE# coil1 . pulse . assert_called_once_with ( ) #NEWLINE# coil2 . pulse . assert_called_once_with ( ) #NEWLINE# assert ( not coil3 . pulse . called ) #NEWLINE# self . machine . switch_controller . process_switch ( 's_ball_switch_launcher' , 0 ) #NEWLINE# self . advance_time_and_run ( 1 ) #NEWLINE# self . assertEquals ( 0 , launcher . balls ) #NEWLINE# self . machine . switch_controller . process_switch ( 's_playfield' , 1 ) #NEWLINE# self . advance_time_and_run ( 0.1 ) #NEWLINE# self . machine . switch_controller . process_switch ( 's_playfield' , 0 ) #NEWLINE# self . advance_time_and_run ( 1 ) #NEWLINE# self . advance_time_and_run ( 10 ) #NEWLINE# self . assertEquals ( 2 , self . machine . ball_controller . num_balls_known ) #NEWLINE# self . advance_time_and_run ( 40 ) #NEWLINE# self . advance_time_and_run ( 40 ) #NEWLINE# self . assertEquals ( 2 , self . machine . ball_controller . num_balls_known ) #NEWLINE# self . assertEquals ( 0 , len ( target . _incoming_balls ) ) #NEWLINE# self . machine . switch_controller . process_switch ( 's_ball_switch1' , 1 ) #NEWLINE# self . advance_time_and_run ( 1 ) #NEWLINE# self . assertEquals ( None , self . machine . game ) #NEWLINE# self . assertEquals ( 2 , self . machine . ball_controller . num_balls_known ) #NEWLINE# self . advance_time_and_run ( 30 ) #NEWLINE# self . assertEquals ( 2 , self . machine . ball_controller . num_balls_known )