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)
def it_loads_last_snapshot_notes(self): collection = PuzzlesCollection() collection.load( INPUT_FILES_ROOT.child('parser_test_last_snapshot_notes.sok') ) title = "This is note for last snapshot, not heading line" note = "but parser can't know that and should recognize it as heading line" assert collection.puzzles[1].title == title assert collection.puzzles[1].notes == note
def it_loads_puzzle_with_multiple_snapshots(self): collection = PuzzlesCollection() collection.load( INPUT_FILES_ROOT.child('parser_test_multiple_snapshots.sok') ) assert len(collection.puzzles[0].snapshots) == 3 assert collection.puzzles[0].snapshots[1].title == ( "This is note for first snapshot, but parser " + "can't know that and should recognize it as heading of next snapshot." )
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 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