def testChooseOptionInputlet(self): from game import autoenv from game.autoenv import user_input from client.core import TheChosenOne, PeerPlayer from thb.thb3v3 import THBattle from thb.inputlets import ChooseOptionInputlet from utils import BatchList autoenv.init('Server') g = THBattle() g.IS_DEBUG = True pl = [create_mock_player([]) for i in xrange(6)] p = pl[0] g.me = p p.client.gdlist.extend([ ['I:ChooseOption:1', True], ['I&:ChooseOption:2', False], ['I|:ChooseOption:3', True], ]) p.client.gdevent.set() g.players = BatchList(pl) hook_game(g) g.gr_groups = WeakSet() ilet = ChooseOptionInputlet(self, (False, True)) eq_(user_input([p], ilet), True) eq_(user_input([p], ilet, type='all'), {p: False}) eq_(user_input([p], ilet, type='any'), (p, True)) for p in pl: eq_(p.client.gdhistory, [ ['RI:ChooseOption:1', True], ['RI&:ChooseOption:2', False], ['RI|:ChooseOption:3', True], ]) autoenv.init('Client') g = THBattle() pl = [PeerPlayer() for i in xrange(6)] svr = MockConnection([ ['RI:ChooseOption:1', True], ['RI&:ChooseOption:2', False], ['RI|:ChooseOption:3', True], ]) p = TheChosenOne(svr) pl[0] = p g.me = p svr.gdevent.set() g.players = BatchList(pl) hook_game(g) assert autoenv.Game.getgame() is g ilet = ChooseOptionInputlet(self, (False, True)) eq_(user_input([p], ilet), True) eq_(user_input([p], ilet, type='all'), {p: False}) eq_(user_input([p], ilet, type='any'), (p, True))