-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
20 lines (19 loc) · 757 Bytes
/
tests.py
File metadata and controls
20 lines (19 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import unittest
from prepare_and_process_image import transform_image
from app import get_prediction
import requests
class FunctionTests(unittest.TestCase):
def test_transforms(self,image = 'static/stop_sign.jpg'):
with open(image,'rb') as f:
image_bytes = f.read()
tensor = transform_image(image_bytes)
print(tensor)
def test_prediction(self, image= 'static/stop_sign.jpg'):
with open(image, 'rb') as f:
image_bytes = f.read()
print(get_prediction(image_bytes))
def test_api(self):
resp = requests.post("http://127.0.0.1:5000/predict",files={"file": open('static/stop_sign.jpg','rb')})
print(resp.json())
if __name__ == '__main__':
unittest.main()