Skip to content

Commit

Permalink
finish test
Browse files Browse the repository at this point in the history
  • Loading branch information
bojiang committed Feb 25, 2021
1 parent 238dd98 commit 02b43a0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
31 changes: 14 additions & 17 deletions tests/integration/projects/general/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,20 @@ def predict_json(self, input_datas):
def customezed_route(self, input_datas):
return input_datas

@bentoml.api(
input=JsonInput(
request_schema={
"application/json": {
"schema": {
"type": "object",
"required": ["field1", "field2"],
"properties": {
"field1": {"type": "string"},
"field2": {"type": "uuid"},
},
},
}
}
),
batch=True,
)
CUSTOM_SCHEMA = {
"application/json": {
"schema": {
"type": "object",
"required": ["field1", "field2"],
"properties": {
"field1": {"type": "string"},
"field2": {"type": "uuid"},
},
},
}
}

@bentoml.api(input=JsonInput(request_schema=CUSTOM_SCHEMA), batch=True)
def customezed_schema(self, input_datas):
return input_datas

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ async def test_api_server_meta(host):

@pytest.mark.asyncio
async def test_customized_request_schema(host):
def has_customized_schema(doc_bytes):
json_str = doc_bytes.decode()
return "field1" in json_str

await pytest.assert_request(
"GET",
f"http://{host}/docs.json",
headers=(("Content-Type", "application/json"),),
assert_data="",
assert_data=has_customized_schema,
)

0 comments on commit 02b43a0

Please sign in to comment.