Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(BAE-22): Restarted this Testing branch and resolved related issues #195

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added Backend/tests/__init__.py
Empty file.
13 changes: 13 additions & 0 deletions Backend/tests/test_api_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/python3
""" TEST FOR API STATUS """
from fastapi.testclient import TestClient
from ..routes.api_status import router

client = TestClient(router)


def test_api_status():
""" Tests the API status """
response = client.get("/")
assert response.status_code == 200
assert response.json() == {"message": "Connection Successful"}
26 changes: 26 additions & 0 deletions Backend/tests/test_delete_statement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from fastapi.testclient import TestClient
from ..routes.delete_documents import router

client = TestClient(router)

def test_delete_statement_success():
""" Tests a successful delete """
url = 'http://127.0.0.1:8000/delete_statement/{filename}'
# file = open(__file__, 'r+')
response = client.delete(url=url)
if response.status_code == 204:
assert {"message": "Successful deletion"}
else:
assert{"message": "Something went wrong"}

def test_delete_statement_record():
""" Tests a successful delete """
url = 'http://127.0.0.1:8000/delete_record/{filename}'
# file = open(__file__, 'r+')
response = client.delete(url=url)
if response.status_code == 204:
assert {"message": "Successful deletion"}
else:
assert {"message": "Something went wrong"}


34 changes: 34 additions & 0 deletions Backend/tests/test_post_account_statement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/python3
""" TEST FOR POST METHOD FOR DOCUMENTS """
import os

from fastapi import UploadFile, File
from fastapi.testclient import TestClient
from ..routes.post_documents import router
from ...config.definitions import ROOT_DIR

client = TestClient(router)

# Returns the relative path for test.csv -> str
def get_rel_path():
return (os.path.join(ROOT_DIR, 'tests', 'test.csv'))

def test_upload_statement_success():



url = 'http://127.0.0.1:8000/upload_statement'
file = open(get_rel_path(), 'rb')
response = client.post(url=url, files=file)






def test_upload_record_success():
url = 'http://127.0.0.1:8000/upload_record'
file = open(r'test.csv')
response = client.post(url=url, files=file)
assert response.status_code == 200

2 changes: 2 additions & 0 deletions config/definitions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import os
ROOT_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))