コード例 #1
0
    def test_controller_end_game(self):
        con = Controller()

        g_id = con.get('get_new_game_instance_ox', '0', 'True')
        out = con.get('end_game_ox', str(g_id), 'name1', '0')

        self.assertEqual(out, None)
コード例 #2
0
    def test_controller_check_game_result_error(self, console_view_mock, model_mock):
        con = Controller()
        model_mock.return_value = model_mock
        model_mock.check_game_result.return_value = False

        g_id = con.get('get_new_game_instance_ox', '0', 'True')
        con.get('check_game_result_ox', str(g_id), 'name1', '0')

        model_mock.check_game_result.assert_called_with(model_mock, 'name1', '0')
        console_view_mock.error.assert_called_with(console_view_mock, model_mock, False)
コード例 #3
0
    def test_controller_add_player_error(self, console_view_mock, model_mock):
        con = Controller()
        model_mock.return_value = model_mock
        model_mock.add_player.return_value = False  # Model's method must return sthg other than None, 0, False

        g_id = con.get('get_new_game_instance_ox', '0', 'True')
        con.get('add_player_ox', str(g_id), 'name1', '0')

        model_mock.add_player.assert_called_with(model_mock, 'name1', '0')
        console_view_mock.error.assert_called_with(console_view_mock, model_mock, False)
コード例 #4
0
    def test_controller_add_player(self, console_view_mock, model_mock):
        con = Controller()
        model_mock.return_value = model_mock
        model_mock.add_player.return_value = True  # Model's method must return sthg other than None, 0, False
        console_view_mock.add_player.return_value = None  # unless we want the Controller to Call OXConsoleView.error

        g_id = con.get('get_new_game_instance_ox', '0', 'True')
        out = con.get('add_player_ox', str(g_id), 'name1', '0')

        self.assertEqual(out, None)  # console_view_mock.add_player.return_value == None
        model_mock.add_player.assert_called_with(model_mock, 'name1', '0')
        console_view_mock.add_player.assert_called_with(console_view_mock, model_mock, True)
コード例 #5
0
    def test_controller_check_game_result(self, console_view_mock, model_mock):
        con = Controller()
        model_mock.return_value = model_mock
        model_mock.check_game_result.return_value = True
        console_view_mock.check_game_result.return_value = None

        g_id = con.get('get_new_game_instance_ox', '0', 'True')
        out = con.get('check_game_result_ox', str(g_id), 'name1', '0')

        self.assertEqual(out, None)
        model_mock.check_game_result.assert_called_with(model_mock, 'name1', '0')
        console_view_mock.check_game_result.assert_called_with(console_view_mock, model_mock, True)
コード例 #6
0
    def test_controller_get_new_game_instance(self, model_mock):
        con = Controller()
        old_guid = con._Controller__game_guid
        model_mock.return_value = model_mock
        model_mock.get_new_game_instance.return_value = True
        g_id = con.get('get_new_game_instance_ox', '0', 'True')

        self.assertEqual(old_guid + 1, g_id)

        model_mock.assert_called_with('0', 'True')
コード例 #7
0
 def test_controller_get_new_game_instance_too_many_games(self, model_mock):
     con = Controller()
     con._Controller__games = {0: '', 1: ''}
     model_mock.return_value = model_mock
     model_mock.get_new_game_instance.return_value = True
     self.assertRaises(OverflowError, con.get('get_new_game_instance_ox', 0))