def test_get_grid_exception_shows_error(Grid): """Ensure that we show an error when an exception is thrown when getting the grid. """ Grid.from_string.side_effect = ValueError("An error occurred") args = { "<grid>": mock.Mock(), } with pytest.raises(SystemExit): _get_grid(args)
def test_get_grid_lowercases(): """Ensure that when we get the grid we lowercase our letters.""" args = { "<grid>": "ABCD", } grid = _get_grid(args) for i, j in grid.tile_indices: assert grid[i, j] == grid[i, j].lower()
def test_get_grid(Grid): """Ensure that we can get a grid from a string.""" grid_string = mock.Mock() grid_string.lower.return_value = grid_string args = { "<grid>": grid_string, } Grid.from_string.return_value = "foo" assert _get_grid(args) == "foo" Grid.from_string.assert_called_once_with(grid_string)