-
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 newtest for API routes interface
- Loading branch information
Showing
6 changed files
with
40 additions
and
6 deletions.
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
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 |
---|---|---|
|
@@ -4,4 +4,4 @@ | |
from mylib import logic | ||
|
||
if __name__ == "__main__": | ||
fire.Fire(logic) | ||
fire.Fire(logic) |
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 |
---|---|---|
@@ -1,21 +1,24 @@ | ||
import wikipedia | ||
from textblob import TextBlob | ||
|
||
|
||
def wiki(name="Monza", lenght=1): | ||
"""This is a Wikipedia fetcher""" | ||
|
||
my_wiki = wikipedia.summary(name, lenght) | ||
return my_wiki | ||
|
||
|
||
def search_wiki(name): | ||
"""Search Wikipedia for Names""" | ||
|
||
results = wikipedia.search(name) | ||
return results | ||
|
||
|
||
def phrase(name): | ||
"""Returns phrases from wikipedia""" | ||
|
||
page = wiki(name) | ||
blob = TextBlob(page) | ||
return blob.noun_phrases |
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,24 @@ | ||
from fastapi.testclient import TestClient | ||
from main import app | ||
|
||
client = TestClient(app) | ||
|
||
|
||
def test_read_main(): | ||
response = client.get("/") | ||
assert response.status_code == 200 | ||
assert response.json() == {"message": "Wikipedia API. Call /search or /wiki"} | ||
|
||
|
||
def test_read_phrase(): | ||
response = client.get("/phrase/Barack Obama") | ||
assert response.status_code == 200 | ||
assert response.json() == { | ||
"result": [ | ||
"barack hussein obama ii", | ||
"bə-rahk hoo-sayn oh-bah-mə", | ||
"august", | ||
"american politician", | ||
"44th president", | ||
] | ||
} |