Ejemplo n.º 1
0
def load_parser_test_data():
    input_file = TEST_RESOURCES_ROOT.child('test_data'
                                          ).child('hexoban_parser_tests.sok')
    collection = PuzzlesCollection()
    collection.load(input_file)

    retv = {}
    for puzzle in collection.puzzles:
        if puzzle.title == "row_added_type1_top" or puzzle.title == "row_added_type2_top":
            puzzle.board = '-' + puzzle.board[1:]
        if puzzle.title == "row_added_type1_bottom" or puzzle.title == "row_added_type2_bottom":
            puzzle.board = puzzle.board[:-2] + '-' + puzzle.board[-1]

        retv[puzzle.title] = puzzle.board.rstrip()

    return retv
Ejemplo n.º 2
0
from helpers import TEST_RESOURCES_ROOT
from sokoenginepy.common import Variant, is_blank
from sokoenginepy.input_output import PuzzlesCollection, SOKFileFormat

INPUT_FILES_ROOT = TEST_RESOURCES_ROOT.child('test_data')


class DescribeSOKReader:

    def it_loads_regular_collection_file(self):
        collection = PuzzlesCollection()
        collection.load(INPUT_FILES_ROOT.child('Original_and_Extra.sok'))

        assert len(collection.puzzles) == 91
        assert len(collection.puzzles[0].snapshots) == 6

        assert collection.puzzles[0].title == 'Level 1'
        assert not is_blank(collection.notes)
        assert not is_blank(collection.puzzles[0].board)
        assert not is_blank(collection.puzzles[0].notes)
        assert not is_blank(collection.puzzles[0].snapshots[0].moves)

    def it_loads_puzzle_without_title(self):
        collection = PuzzlesCollection()
        collection.load(
            INPUT_FILES_ROOT.child('parser_test_puzzle_no_title.sok')
        )

        assert is_blank(collection.puzzles[0].title)
        assert not is_blank(collection.puzzles[0].board)