Esempio n. 1
0
    def test_can_save_and_retrieve_with_pickled_data(self):
        game = Game()
        data = '12345'
        game.data = pickle.dumps(data)

        game.save()
        saved_game = Game.objects.first()

        assert pickle.loads(saved_game.data) == data
Esempio n. 2
0
    def test_color_from_player(self):
        game = Game()

        color1 = game.player_color('1')
        color2 = game.player_color('2')
        empty = game.player_color('.')

        assert color1 == 'red'
        assert color2 == 'blue'
        assert empty is None
Esempio n. 3
0
    def test_move_calls_datas_move(self, mock_loads, mock_dumps):
        mock_core_game = Mock()
        mock_loads.return_value = mock_core_game
        mock_dumps.return_value = 'dumps return'
        game = Game()
        game.data = 'game data'

        game.move(current_x=1, current_y=2, new_x=3, new_y=4)

        assert mock_loads.call_args == (('game data',), {})
        assert mock_core_game.make_move.called
        assert mock_core_game.make_move.call_args == (((1, 2), (3, 4)), {})
        assert game.data == 'dumps return'