<s> import os <EOL> import random <EOL> import unittest <EOL> from approvaltests import Approvals <EOL> from approvaltests . TextDiffReporter import TextDiffReporter <EOL> from Infrastructure . MobberManager import MobberManager <EOL> os . environ [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> class TestsMobberManager ( unittest . TestCase ) : <EOL> def test_empty_mobber_manager_has_no_items ( self ) : <EOL> mobber_manager = MobberManager ( ) <EOL> self . assertEqual ( mobber_manager . mobber_count ( ) , <NUM_LIT:0> ) <EOL> def test_add_mobber_chris_has_chris ( self ) : <EOL> mobber_manager = MobberManager ( ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> result = [ "<STR_LIT>" ] <EOL> self . assertEqual ( mobber_manager . get_mobbers ( ) , result ) <EOL> def test_add_mobber_joe_chris_has_joe_chris ( self ) : <EOL> mobber_manager = MobberManager ( ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> result = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> self . assertEqual ( mobber_manager . get_mobbers ( ) , result ) <EOL> def test_add_mobber_joe_chris_joe__remove_joe_has_joe_chris ( self ) : <EOL> mobber_manager = MobberManager ( ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . remove_mobber ( <NUM_LIT:2> ) <EOL> result = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> self . assertEqual ( mobber_manager . get_mobbers ( ) , result ) <EOL> def test_add_4_mobbers_move_up_middle ( self ) : <EOL> mobber_manager = MobberManager ( ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . move_mobber_up ( <NUM_LIT:2> ) <EOL> result = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> self . assertEqual ( mobber_manager . get_mobbers ( ) , result ) <EOL> def test_add_4_mobbers_move_up_top ( self ) : <EOL> mobber_manager = MobberManager ( ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . move_mobber_up ( <NUM_LIT:0> ) <EOL> result = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> self . assertEqual ( mobber_manager . get_mobbers ( ) , result ) <EOL> def test_add_4_mobbers_move_down_middle ( self ) : <EOL> mobber_manager = MobberManager ( ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . move_mobber_down ( <NUM_LIT:2> ) <EOL> result = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> self . assertEqual ( mobber_manager . get_mobbers ( ) , result ) <EOL> def test_add_4_mobbers_move_down_bottom ( self ) : <EOL> mobber_manager = MobberManager ( ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . move_mobber_down ( <NUM_LIT:3> ) <EOL> result = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> self . assertEqual ( mobber_manager . get_mobbers ( ) , result ) <EOL> def test_move_down_empty ( self ) : <EOL> mobber_manager = MobberManager ( ) <EOL> mobber_manager . move_mobber_down ( <NUM_LIT:0> ) <EOL> result = [ ] <EOL> self . assertEqual ( mobber_manager . get_mobbers ( ) , result ) <EOL> def test_move_up_empty ( self ) : <EOL> mobber_manager = MobberManager ( ) <EOL> mobber_manager . move_mobber_up ( <NUM_LIT:0> ) <EOL> result = [ ] <EOL> self . assertEqual ( mobber_manager . get_mobbers ( ) , result ) <EOL> def test_remove_empty ( self ) : <EOL> mobber_manager = MobberManager ( ) <EOL> mobber_manager . remove_mobber ( <NUM_LIT:0> ) <EOL> result = [ ] <EOL> self . assertEqual ( mobber_manager . get_mobbers ( ) , result ) <EOL> def test_clear ( self ) : <EOL> mobber_manager = MobberManager ( ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . clear ( ) <EOL> result = [ ] <EOL> self . assertEqual ( mobber_manager . get_mobbers ( ) , result ) <EOL> def test_subscribe_to_mobber_list_changes ( self ) : <EOL> mobber_manager = MobberManager ( ) <EOL> result = { "<STR_LIT:result>" : "<STR_LIT>" , "<STR_LIT>" : <NUM_LIT:0> } <EOL> def time_change_callback ( mobber_list , driver_index , navigator_index ) : <EOL> result [ "<STR_LIT>" ] += <NUM_LIT:1> <EOL> result [ "<STR_LIT:result>" ] += "<STR_LIT>" + result [ "<STR_LIT>" ] . __str__ ( ) + "<STR_LIT::>" <EOL> for mobber_index in range ( <NUM_LIT:0> , mobber_list . __len__ ( ) ) : <EOL> result [ "<STR_LIT:result>" ] += mobber_list [ mobber_index ] <EOL> if mobber_index == driver_index : <EOL> result [ "<STR_LIT:result>" ] += "<STR_LIT>" <EOL> if mobber_index == navigator_index : <EOL> result [ "<STR_LIT:result>" ] += "<STR_LIT>" <EOL> result [ "<STR_LIT:result>" ] += "<STR_LIT:U+002CU+0020>" <EOL> result [ "<STR_LIT:result>" ] += "<STR_LIT:\n>" <EOL> mobber_manager . subscribe_to_mobber_list_change ( time_change_callback ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . switch_next_driver ( ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . switch_next_driver ( ) <EOL> mobber_manager . switch_next_driver ( ) <EOL> mobber_manager . switch_next_driver ( ) <EOL> mobber_manager . switch_next_driver ( ) <EOL> mobber_manager . switch_next_driver ( ) <EOL> mobber_manager . remove_mobber ( <NUM_LIT:2> ) <EOL> mobber_manager . remove_mobber ( <NUM_LIT:0> ) <EOL> mobber_manager . switch_next_driver ( ) <EOL> mobber_manager . rewind_driver ( ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . rewind_driver ( ) <EOL> mobber_manager . rewind_driver ( ) <EOL> mobber_manager . rewind_driver ( ) <EOL> mobber_manager . move_mobber_down ( <NUM_LIT:0> ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . move_mobber_up ( <NUM_LIT:2> ) <EOL> mobber_manager . remove_mobber ( <NUM_LIT:1> ) <EOL> mobber_manager . remove_mobber ( <NUM_LIT:0> ) <EOL> mobber_manager . remove_mobber ( <NUM_LIT:0> ) <EOL> Approvals . verify ( result [ "<STR_LIT:result>" ] , TextDiffReporter ( ) ) <EOL> def test_subscribe_to_mobber_list_changes_random ( self ) : <EOL> random . seed ( <NUM_LIT:0> ) <EOL> mobber_manager = MobberManager ( True ) <EOL> result = { "<STR_LIT:result>" : "<STR_LIT>" , "<STR_LIT>" : <NUM_LIT:0> } <EOL> def time_change_callback ( mobber_list , driver_index , navigator_index ) : <EOL> result [ "<STR_LIT>" ] += <NUM_LIT:1> <EOL> result [ "<STR_LIT:result>" ] += "<STR_LIT>" + result [ "<STR_LIT>" ] . __str__ ( ) + "<STR_LIT::>" <EOL> for mobber_index in range ( <NUM_LIT:0> , mobber_list . __len__ ( ) ) : <EOL> result [ "<STR_LIT:result>" ] += mobber_list [ mobber_index ] <EOL> if mobber_index == driver_index : <EOL> result [ "<STR_LIT:result>" ] += "<STR_LIT>" <EOL> if mobber_index == navigator_index : <EOL> result [ "<STR_LIT:result>" ] += "<STR_LIT>" <EOL> result [ "<STR_LIT:result>" ] += "<STR_LIT:U+002CU+0020>" <EOL> result [ "<STR_LIT:result>" ] += "<STR_LIT:\n>" <EOL> mobber_manager . subscribe_to_mobber_list_change ( time_change_callback ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . switch_next_driver ( ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . switch_next_driver ( ) <EOL> mobber_manager . switch_next_driver ( ) <EOL> mobber_manager . switch_next_driver ( ) <EOL> mobber_manager . set_mobber_list ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> mobber_manager . switch_next_driver ( ) <EOL> mobber_manager . switch_next_driver ( ) <EOL> mobber_manager . remove_mobber ( <NUM_LIT:2> ) <EOL> mobber_manager . remove_mobber ( <NUM_LIT:0> ) <EOL> mobber_manager . switch_next_driver ( ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . move_mobber_down ( <NUM_LIT:0> ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . move_mobber_up ( <NUM_LIT:2> ) <EOL> mobber_manager . remove_mobber ( <NUM_LIT:1> ) <EOL> mobber_manager . remove_mobber ( <NUM_LIT:0> ) <EOL> mobber_manager . remove_mobber ( <NUM_LIT:0> ) <EOL> Approvals . verify ( result [ "<STR_LIT:result>" ] , TextDiffReporter ( ) ) <EOL> def test_navigator1_driver0_index ( self ) : <EOL> mobber_manager = MobberManager ( ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> result = "<STR_LIT>" + str ( mobber_manager . next_driver_index ) + "<STR_LIT>" + str ( mobber_manager . driver_index ) <EOL> self . assertEqual ( result , "<STR_LIT>" ) <EOL> def test_switch_navigator0_driver1_index ( self ) : <EOL> mobber_manager = MobberManager ( ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . add_mobber ( "<STR_LIT>" ) <EOL> mobber_manager . switch_next_driver ( ) <EOL> result = "<STR_LIT>" + str ( mobber_manager . next_driver_index ) + "<STR_LIT>" + str ( mobber_manager . driver_index ) <EOL> self . assertEqual ( result , "<STR_LIT>" ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
