mirror of
https://github.com/LukeHagar/connexion.git
synced 2025-12-06 04:19:26 +00:00
Add test for multiple float path parameters
This commit is contained in:
@@ -28,3 +28,8 @@ paths:
|
||||
schema:
|
||||
type: string
|
||||
example: "dave"
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
|
||||
@@ -181,6 +181,19 @@ def test_path_parameter_somefloat(simple_app, arg, result):
|
||||
assert resp.text == f'"{result}"\n'
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"arg, arg2, result",
|
||||
[
|
||||
["-0.000000001", "0.3", "float -1e-09, 0.3"],
|
||||
],
|
||||
)
|
||||
def test_path_parameter_doublefloat(simple_app, arg, arg2, result):
|
||||
assert isinstance(arg, str) and isinstance(arg2, str) # sanity check
|
||||
app_client = simple_app.test_client()
|
||||
resp = app_client.get(f"/v1.0/test-float-path/{arg}/{arg2}")
|
||||
assert resp.text == f'"{result}"\n'
|
||||
|
||||
|
||||
def test_path_parameter_somefloat__bad(simple_app):
|
||||
# non-float values will not match Flask route
|
||||
app_client = simple_app.test_client()
|
||||
|
||||
@@ -280,6 +280,10 @@ def test_get_somefloat(somefloat):
|
||||
return f"{type(somefloat).__name__} {somefloat:g}"
|
||||
|
||||
|
||||
def test_get_doublefloat(somefloat, someotherfloat):
|
||||
return f"{type(somefloat).__name__} {somefloat:g}, {someotherfloat}"
|
||||
|
||||
|
||||
def test_default_param(name):
|
||||
return {"app_name": name}
|
||||
|
||||
|
||||
18
tests/fixtures/simple/openapi.yaml
vendored
18
tests/fixtures/simple/openapi.yaml
vendored
@@ -526,6 +526,24 @@ paths:
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
'/test-float-path/{somefloat}/{someotherfloat}':
|
||||
get:
|
||||
summary: Test type casting of path parameter
|
||||
operationId: fakeapi.hello.test_get_doublefloat
|
||||
parameters:
|
||||
- name: somefloat
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: number
|
||||
- name: someotherfloat
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: number
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
/test-default-query-parameter:
|
||||
get:
|
||||
summary: Test if default parameter is passed to function
|
||||
|
||||
17
tests/fixtures/simple/swagger.yaml
vendored
17
tests/fixtures/simple/swagger.yaml
vendored
@@ -394,6 +394,23 @@ paths:
|
||||
200:
|
||||
description: OK
|
||||
|
||||
/test-float-path/{somefloat}/{someotherfloat}:
|
||||
get:
|
||||
summary: Test type casting of path parameter
|
||||
operationId: fakeapi.hello.test_get_doublefloat
|
||||
parameters:
|
||||
- name: somefloat
|
||||
in: path
|
||||
type: number
|
||||
required: true
|
||||
- name: someotherfloat
|
||||
in: path
|
||||
type: number
|
||||
required: true
|
||||
responses:
|
||||
200:
|
||||
description: O
|
||||
|
||||
/test-default-query-parameter:
|
||||
get:
|
||||
summary: Test if default parameter is passed to function
|
||||
|
||||
Reference in New Issue
Block a user