Example #1
0
    def test_restore(self):
        """
        Focus on making moves with storing and restoring game objects.
        """
        
        # Load the test level. 
        test_level_path = os.path.join('source', 'game', 'tests', 'resources', 'test_game_level')

        # Parse the test file into a string.
        board_file = open(test_level_path, 'r')
        board_string = board_file.read()
        board_file.close()

        # Create Game using the newly-created board_string.
        game = Game.new_game(board_string)

        # Restore the game.
        restored_game = Game.restore(game)

        # Make sure first and second player can alternate moves post-restore.
        resp = restored_game.make_move([0,0], [2,2])
        assert resp.move_status is True
        resp = restored_game.make_move([6,6], [4,4])
        assert resp.move_status is True
        
        # Restore the game.
        restored_game = Game.restore(game)
        
        # Make sure that the position of pieces are stored properly.
        resp = restored_game.make_move([2,2], [0,0])
        assert resp.move_status is True
        resp = restored_game.make_move([4,4], [6,6])
        assert resp.move_status is True