-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added simple router * included basic router to the main
- Loading branch information
1 parent
ad44d11
commit 2dab53e
Showing
4 changed files
with
44 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import logging | ||
|
||
from fastapi import APIRouter | ||
|
||
|
||
LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
def create_api_router() -> APIRouter: | ||
router = APIRouter() | ||
|
||
@router.get("/v1/extract-keywords") | ||
def extract_keywords(text: str): | ||
return text.split() | ||
|
||
return router |
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,18 @@ | ||
from fastapi.testclient import TestClient | ||
from fastapi import FastAPI | ||
|
||
from spacy_keyword_extraction_api.api_router import create_api_router | ||
|
||
|
||
def create_test_client(): | ||
app = FastAPI() | ||
app.include_router(create_api_router()) | ||
client = TestClient(app) | ||
return client | ||
|
||
|
||
class TestExtractKeyword: | ||
def test_should_return_keywords(self): | ||
client = create_test_client() | ||
response = client.get('/v1/extract-keywords', params={'text': 'some text'}) | ||
assert response.json() == ['some', 'text'] |
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