-
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: Test cases of the api and CI-CD pipeline
- Loading branch information
Showing
7 changed files
with
98 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Run Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
name: Test FastAPI Application | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Run Tests | ||
run: | | ||
pytest test_main.py |
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,3 +1,4 @@ | ||
__pycache__/ | ||
venv/ | ||
.env | ||
.env | ||
.pytest_cache/ |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,61 @@ | ||
from fastapi.testclient import TestClient | ||
from api import app | ||
from mongo import MongoDB | ||
|
||
client = TestClient(app) | ||
db = MongoDB() | ||
|
||
|
||
def test_invoice_extractor(): | ||
image_file = open("data\invoice.png", "rb") | ||
files = {"image_file": image_file} | ||
data = {"prompt": "To whom this invoice belongs"} | ||
|
||
response = client.post("/invoice_extractor", files=files, data=data) | ||
assert response.status_code == 200 | ||
assert "response" in response.json() | ||
|
||
def test_blogs(): | ||
data = {"topic": "Tensorflow"} | ||
|
||
response = client.post("/blog_generator", data=data) | ||
assert response.status_code == 200 | ||
assert "response" in response.json() | ||
|
||
def test_sql_query(): | ||
data = {"prompt": "Tell me the employees living in city Noida"} | ||
|
||
response = client.post("/Text2SQL", data=data) | ||
assert response.status_code == 200 | ||
assert "response" in response.json() | ||
|
||
def test_youtube_video_transcribe_summarizer(): | ||
data = {"url": "https://www.youtube.com/watch?v=voexVsTHPBY&ab_channel=NabeelNawab"} | ||
|
||
response = client.post("/youtube_video_transcribe_summarizer", data=data) | ||
assert response.status_code == 200 | ||
assert "response" in response.json() | ||
|
||
def test_nutritionist_expert(): | ||
image_file = open(r"data\burger.jpg", "rb") | ||
data = {"height": "165", "weight": "70"} | ||
|
||
response = client.post("/nutritionist_expert", files={"image_file": image_file}, data=data) | ||
assert response.status_code == 200 | ||
assert "response" in response.json() | ||
|
||
def test_talk2PDF(): | ||
pdf_file = open(r"data\yolo.pdf", "rb") | ||
data = {"prompt": "Summary in 200 words"} | ||
|
||
response = client.post("/talk2PDF", files={"pdf": pdf_file}, data=data) | ||
assert response.status_code == 200 | ||
assert "response" in response.json() | ||
|
||
def test_questions_generator(): | ||
pdf_file = open(r"data\yolo.pdf", "rb") | ||
|
||
# Make a request to the questions_generator endpoint | ||
response = client.post("/questions_generator", files={"pdf": pdf_file}) | ||
assert response.status_code == 200 | ||
assert "response" in response.json() |