forked from RaymondDashWu/nlp_sentiment_classifier
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver_test.py
More file actions
45 lines (36 loc) · 1.42 KB
/
server_test.py
File metadata and controls
45 lines (36 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!python
from starlette.responses import HTMLResponse
from starlette.testclient import TestClient
import unittest
# NOTE: Unknown pickling error. Unable to test any prediction functionalities
# import app.server
# TODO tests to write:
# - [X] 200 response on website
# - [X] 200 response on model download
# - [ ] response time
# - Ask CTO stated that it should be less than 100 ms response
# - [ ] assert negative and errors with confidence levels above X
#
# NOTE: On hold due to machine learning server being down
# TODO Combinations of words that gave false positive predictions
# slickly great but also somewhat bad
# slickly good but also bad
# The movie displayed lot of nudity and had a theme that showed corruption within a city
class App:
def __init__(self, scope):
assert scope['type'] == 'http'
self.scope = scope
async def __call__(self, receive, send):
response = HTMLResponse()
await response(receive, send)
class ServerTest(unittest.TestCase):
def test_website(self):
client = TestClient(App)
response = client.get('https://sentiment-classifier-restart2.onrender.com/')
assert response.status_code == 200
def test_download_model(self):
client = TestClient(App)
response = client.get('https://www.dropbox.com/s/xhnvw0axn6xjbk9/export.pkl?dl=1')
assert response.status_code == 200
if __name__ == '__main__':
unittest.main()