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

Bae 60 backend testing #202

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
7 changes: 6 additions & 1 deletion Backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,28 @@ colorama==0.4.6
distro==1.8.0
et-xmlfile==1.1.0
fastapi==0.87.0
flake8==6.0.0
greenlet==2.0.1
gunicorn==20.1.0
h11==0.14.0
httpcore==0.16.1
httptools==0.5.0
httpx==0.23.1
idna==3.4
mccabe==0.7.0
mysql-connector-python==8.0.31
newrelic==8.4.0
numpy==1.23.5
openai==0.25.0
opencv-python==4.6.0.66
openpyxl==3.0.10
pandas==1.5.2
pandas-stubs==1.5.2.221124
pdfkit==1.0.0
protobuf==3.20.1
pycodestyle==2.10.0
pydantic==1.10.2
pyflakes==3.0.1
PyMySQL==1.0.2
PyMysqlDB==0.0.2
python-dateutil==2.8.2
Expand All @@ -42,7 +47,7 @@ starlette==0.21.0
tabula-py==2.6.0
tqdm==4.64.1
types-pytz==2022.6.0.1
typing-extensions==4.4.0
typing_extensions==4.4.0
urllib3==1.26.13
uvicorn==0.19.0
uvloop==0.17.0
Expand Down
1 change: 1 addition & 0 deletions tests/test_backend/flask8_script.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flake8 Backenf
40 changes: 39 additions & 1 deletion tests/test_backend/test_controllers/test_convert_file.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,40 @@
#!/usr/bin/python3
""" TEST FOR CONVERT FILE FUNCTIONS """
""" TEST FOR CONVERT FILE FUNCTIONS """
from fastapi.testclient import TestClient
from fastapi import File, UploadFile, FASTAPI
from fastapi import Response, status

app = FASTAPI()

def read_root():
return {"Hello": "World"}

client = TestClient(app)
test_file = ["dummy_account_statement.csv", "dummy_sales_record.csv",]

# def test_file_conversion(filename):
# response = client.post("/upload")
# files = [("files", open("dummy_account_statement.csv", "rb")), ("files", open("dummy_sales_record.csv", "rb"))]
# #TODO how to upload a file
# # Initialize an empty string to store the letters after the period
# letters_after_period = ""

# # Loop through each character in the string
# for ch in test_file:
# # Check if the current character is a period
# if ch == ".":
# # If it is, save all the remaining characters in the string after the period
# letters_after_period = test_file[test_file.index(ch)+1:]

# # Print the letters after the period
# print(letters_after_period)

# assert response.status_code == 200
# assert response.j


def test_file_upload():
files = [("files", open("dummy_account_statement.csv", "rb")), ("files", open("dummy_sales_record.csv", "rb"))]
#TODO how to upload a file
response = client.post('/upload', files=files)
assert response.status_code == status.HTTP_201_CREATED