def test_find_maze_not_found(bomb): """Test (not) finding a maze with invalid greens.""" maze = Maze(bomb) maze.set_greens([(10, 10), (0, 0)]) # greens won't match any maze expected_exception = 'No maze found for greens {}'.format(maze.greens) with pytest.raises(Exception, message=expected_exception): maze.find_maze()
def test_set_goal(bomb): """Test setting the goal for the maze.""" goal = (0, 1) maze = Maze(bomb) maze.set_goal(goal) actual = maze.goal expected = goal assert actual == expected
def test_get_instructions(bomb, test_mazes): """Test getting natural language instructions for solving a maze.""" maze = Maze(bomb) test_maze = test_mazes[0] path = test_maze['path'] actual = maze.get_instructions(path) expected = test_maze['instructions'] assert actual == expected
def test_find_path(bomb, test_mazes): """Test finding paths through each maze.""" maze = Maze(bomb) for test_maze in test_mazes: maze.set_start(test_maze['start']) maze.set_goal(test_maze['goal']) maze.set_greens(test_maze['greens']) actual = maze.find_path() expected = test_maze['path'] assert actual == expected
def test_set_start(bomb): """Test setting the start for the maze.""" start = (0, 1) maze = Maze(bomb) maze.set_start(start) actual = maze.start expected = start assert actual == expected
def test_find_maze(bomb, test_mazes): """Test finding mazes.""" maze = Maze(bomb) maze.load_mazes() for test_maze in test_mazes: maze.set_greens(test_maze['greens']) actual = maze.find_maze() expected = test_maze['data'] assert actual == expected
def test_add_green(bomb): """Test adding greens to a maze.""" greens = [(0, 1), (2, 3)] maze = Maze(bomb) maze.add_green(greens[0]) actual = maze.greens expected = [greens[0]] assert actual == expected maze.add_green(greens[1]) actual = maze.greens expected = greens assert actual == expected
def test_set_greens(bomb): """Test setting (overwriting) greens on a maze.""" maze = Maze(bomb) original_greens = [(0, 1), (2, 3)] maze.set_greens(original_greens) actual = maze.greens expected = original_greens assert actual == expected new_greens = [(4, 5), (6, 7)] maze.set_greens(new_greens) actual = maze.greens expected = new_greens assert actual == expected
def test_load_mazes(bomb, test_mazes): """Test loading mazes from a file.""" # TODO: this could probably be more thorough. maze = Maze(bomb) popped_test_mazes = [] for test_maze in test_mazes: test_maze.pop('start') test_maze.pop('goal') test_maze.pop('path') test_maze.pop('instructions') popped_test_mazes.append(test_maze) actual = maze.load_mazes() expected = popped_test_mazes assert actual == expected