Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aniketmaurya committed Dec 11, 2024
1 parent 863fbcf commit b47bc10
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tests/test_litapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def predict():


def test_encode_response_with_custom_spec_api():
class CustomSpecAPI(ls.test_examples.TestAPI):
class CustomSpecAPI(ls.OpenAISpec):
def encode_response(self, output_stream):
for output in output_stream:
yield {"content": output}
Expand Down
14 changes: 5 additions & 9 deletions tests/test_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,11 @@ def encode_response(self, output):

@pytest.mark.asyncio
async def test_openai_spec_validation(openai_request_data):
server = ls.LitServer(IncorrectAPI1(), spec=OpenAISpec())
with pytest.raises(ValueError, match="predict is not a generator"), wrap_litserve_start(server) as server:
async with LifespanManager(server.app) as manager:
await manager.shutdown()

server = ls.LitServer(IncorrectAPI2(), spec=OpenAISpec())
with pytest.raises(ValueError, match="encode_response is not a generator"), wrap_litserve_start(server) as server:
async with LifespanManager(server.app) as manager:
await manager.shutdown()
with pytest.raises(ValueError, match="predict is not a generator"):
ls.LitServer(IncorrectAPI1(), spec=OpenAISpec())

with pytest.raises(ValueError, match="encode_response is not a generator"):
ls.LitServer(IncorrectAPI2(), spec=OpenAISpec())


class PrePopulatedAPI(ls.LitAPI):
Expand Down

0 comments on commit b47bc10

Please sign in to comment.