generated from aniketmaurya/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7d3a2a
commit 8e4383d
Showing
3 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
"""A Python Project""" | ||
from .base_fastserve import FastServe | ||
|
||
__version__ = "0.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pytest | ||
from fastserve import FastServe | ||
from fastserve.core import BaseRequest | ||
|
||
|
||
class FakeServe(FastServe): | ||
def handle(self, batch): | ||
return [1] * len(batch) | ||
|
||
|
||
def test_handle(): | ||
serve = FastServe() | ||
batch = [BaseRequest(request=1), BaseRequest(request=2)] | ||
with pytest.raises(NotImplementedError): | ||
serve.handle(batch) | ||
|
||
serve = FakeServe() | ||
assert serve.handle(batch) == [1, 1] | ||
|
||
|
||
def test_run_server(): | ||
serve = FakeServe() | ||
serve._serve() | ||
test_client = serve.test_client | ||
data = BaseRequest(request=1).model_dump_json() | ||
response = test_client.post("/endpoint", data=data) | ||
assert response.status_code == 200 | ||
assert response.json() == 1 |