コード例 #1
0
ファイル: test_models.py プロジェクト: Wilfcastle/colonies
    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
コード例 #2
0
ファイル: test_models.py プロジェクト: Wilfcastle/colonies
    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'