#NEWLINE# def test_lock_and_release_at_game_end( 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# lock = self . machine . ball_devices [ 'test_lock' ] #NEWLINE# lock_logic = self . machine . ball_locks [ 'lock_test' ] #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 . _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# 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_active' , 1 ) #NEWLINE# self . advance_time_and_run ( 0.1 ) #NEWLINE# self . machine . switch_controller . process_switch ( 's_playfield_active' , 0 ) #NEWLINE# self . advance_time_and_run ( 1 ) #NEWLINE# self . assertEquals ( 1 , playfield . balls ) #NEWLINE# self . assertEquals ( 0 , self . _captured ) #NEWLINE# self . assertEquals ( 0 , self . _missing ) #NEWLINE# coil1 . pulse = MagicMock ( ) #NEWLINE# coil2 . pulse = MagicMock ( ) #NEWLINE# coil3 . pulse = MagicMock ( ) #NEWLINE# self . machine . switch_controller . process_switch ( 's_ball_switch_lock1' , 1 ) #NEWLINE# self . advance_time_and_run ( 1 ) #NEWLINE# self . assertEquals ( 1 , lock . balls ) #NEWLINE# coil1 . pulse . assert_called_once_with ( ) #NEWLINE# assert ( not coil2 . pulse . called ) #NEWLINE# assert ( not coil3 . pulse . called ) #NEWLINE# self . assertEquals ( 0 , playfield . balls ) #NEWLINE# self . assertEquals ( 1 , self . _captured ) #NEWLINE# self . assertEquals ( 0 , self . _missing ) #NEWLINE# self . assertEquals ( 1 , lock_logic . balls_locked ) #NEWLINE# self . _captured = 0 #NEWLINE# self . machine . switch_controller . process_switch ( 's_ball_switch2' , 0 ) #NEWLINE# self . advance_time_and_run ( 1 ) #NEWLINE# self . assertEquals ( 0 , 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_active' , 1 ) #NEWLINE# self . advance_time_and_run ( 0.1 ) #NEWLINE# self . machine . switch_controller . process_switch ( 's_playfield_active' , 0 ) #NEWLINE# self . advance_time_and_run ( 1 ) #NEWLINE# self . assertEquals ( 1 , playfield . balls ) #NEWLINE# self . assertEquals ( 0 , self . _captured ) #NEWLINE# self . assertEquals ( 0 , self . _missing ) #NEWLINE# self . machine . switch_controller . process_switch ( 's_ball_switch1' , 1 ) #NEWLINE# self . advance_time_and_run ( 1 ) #NEWLINE# self . assertEquals ( 0 , playfield . balls ) #NEWLINE# self . assertEquals ( 1 , self . _captured ) #NEWLINE# self . assertEquals ( 0 , self . _missing ) #NEWLINE# self . _captured = 0 #NEWLINE# self . assertEquals ( 2 , self . machine . ball_controller . num_balls_known ) #NEWLINE# coil1 . pulse . assert_called_once_with ( ) #NEWLINE# coil2 . pulse . assert_called_once_with ( ) #NEWLINE# coil3 . pulse . assert_called_once_with ( ) #NEWLINE# self . machine . switch_controller . process_switch ( 's_ball_switch_lock1' , 0 ) #NEWLINE# self . advance_time_and_run ( 1 ) #NEWLINE# self . assertEquals ( 0 , lock . balls ) #NEWLINE# self . assertEquals ( 0 , lock_logic . balls_locked ) #NEWLINE# self . assertEquals ( 0 , self . _captured ) #NEWLINE# self . assertEquals ( 0 , self . _missing ) #NEWLINE# self . assertEquals ( 0 , self . _collecting_balls_complete ) #NEWLINE# self . machine . switch_controller . process_switch ( 's_ball_switch2' , 1 ) #NEWLINE# self . advance_time_and_run ( 1 ) #NEWLINE# self . assertEquals ( 0 , playfield . balls ) #NEWLINE# self . assertEquals ( 1 , self . _captured ) #NEWLINE# self . assertEquals ( 0 , self . _missing ) #NEWLINE# self . assertEquals ( 2 , self . machine . ball_controller . num_balls_known ) #NEWLINE# self . assertEquals ( 1 , self . _collecting_balls_complete ) #NEWLINE# self . advance_time_and_run ( 100 ) #NEWLINE# self . assertEquals ( 0 , playfield . balls ) #NEWLINE# self . assertEquals ( 1 , self . _captured ) #NEWLINE# self . assertEquals ( 0 , self . _missing ) #NEWLINE# self . assertEquals ( 2 , self . machine . ball_controller . num_balls_known ) #NEWLINE# self . assertEquals ( 1 , self . _collecting_balls_complete )