def clear(current_user, id): """ Clear a cell swagger_from_file: src/swagger/game_clear_cell.yml """ data = request.get_json(silent=True) schema = CellAction() try: game = find_game(current_user.id, id) service = GameService(game) except GameNotFoundException as gnf: return jsonify({"message": str(gnf)}), 404 try: coords = schema.load(data) except ValidationError as err: return jsonify(err.messages), 400 try: service.clear(coords["row"], coords["column"]) update_game(current_user.id, id, service.game) except InvalidClearException as exc: return jsonify({"message": str(exc)}), 400 return jsonify(service.encode_game_info())
def test_toggle_uncovered_cell_should_do_nothing(): service = GameService(get_mock_game()) service.start_game(1, 10, 10, 20) board = service.game.board board[0][0]["value"] = 0 service.clear(0, 0) assert board[0][0]["status"] == "U" service.toggle(0, 0) assert board[0][0]["status"] == "U"