Skip to content

Commit

Permalink
test: Add tests for encoding errors on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Dygalo <dmitry@dygalo.dev>
  • Loading branch information
Stranger6667 committed May 8, 2024
1 parent bef643e commit 71be41c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,24 @@ jobs:
uses: codecov/codecov-action@v4.3.1
with:
token: ${{ secrets.CODECOV_TOKEN }}

tests-windows-smoke-test:
runs-on: windows-2019
name: Testing corner cases of CLI output on Windows
steps:
- uses: actions/checkout@v4.1.4
with:
fetch-depth: 1

- uses: actions/setup-python@v5
with:
python-version: "3.12"

- run: pip install ".[dev]"

- run: bash test_server.sh --spec=openapi3 --operations=unicode 8081 &
shell: bash

- run: st run http://127.0.0.1:8081/schema.yaml > output.txt

- run: cat output.txt
1 change: 1 addition & 0 deletions test/apps/openapi/_aiohttp/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,3 +291,4 @@ async def update_user(request: web.Request) -> web.Response:
invalid = success
invalid_path_parameter = success
missing_path_parameter = success
unicode = failure
4 changes: 4 additions & 0 deletions test/apps/openapi/_flask/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def conformance():
def failure():
raise InternalServerError

@app.route("/api/unicode", methods=["POST"])
def unicode():
raise InternalServerError

@app.route("/api/multiple_failures", methods=["GET"])
def multiple_failures():
try:
Expand Down
12 changes: 12 additions & 0 deletions test/apps/openapi/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class Operation(Enum):
read_only = ("GET", "/api/read_only")
write_only = ("POST", "/api/write_only")

unicode = ("POST", "/api/unicode")

create_user = ("POST", "/api/users/")
get_user = ("GET", "/api/users/{user_id}")
update_user = ("PATCH", "/api/users/{user_id}")
Expand Down Expand Up @@ -199,6 +201,11 @@ def add_read_write_only():
"parameters": [{"name": "id", "in": "query", "required": True, "type": "int"}],
"responses": {"200": {"description": "OK"}},
}
elif name == "unicode":
schema = {
"parameters": [{"name": "value", "in": "body", "required": True, "schema": {"enum": ["└"]}}],
"responses": {"200": {"description": "OK"}},
}
elif name == "upload_file":
schema = {
"parameters": [
Expand Down Expand Up @@ -550,6 +557,11 @@ def add_link(name, definition):
"parameters": [{"name": "id", "in": "query", "required": True, "schema": {"type": "int"}}],
"responses": {"200": {"description": "OK"}},
}
elif name == "unicode":
schema = {
"requestBody": {"content": {"application/json": {"schema": {"enum": ["└"]}}}, "required": True},
"responses": {"200": {"description": "OK"}},
}
elif name == "upload_file":
schema = {
"requestBody": {
Expand Down

0 comments on commit 71be41c

Please sign in to comment.