forked from vedangj044/News_stock_prediction
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_appSocket.py
43 lines (36 loc) · 1.49 KB
/
test_appSocket.py
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
import unittest
from fastapi.testclient import TestClient
from appWebSocket import app
class socketCases(unittest.TestCase):
def test_emptyQuery(self):
self.client = TestClient(app)
with self.client.websocket_connect("/ws") as ws:
ws.send_text("")
data = ws.receive_json()
assert 'Invalid query' in data['message']
def test_invalidQuery(self):
self.client = TestClient(app)
with self.client.websocket_connect("/ws") as ws:
ws.send_text("case;';';';';'eenadue'")
data = ws.receive_json()
assert 'Google' in data['message']
def test_invalidTicker(self):
self.client = TestClient(app)
with self.client.websocket_connect("/ws") as ws:
ws.send_text("narendramodi")
data = ws.receive_json()
assert 'brand' in data['message']
def test_flow(self):
self.client = TestClient(app)
with self.client.websocket_connect("/ws") as ws:
ws.send_text("tesla")
data = ws.receive_json()
assert 'predictedPrice' in data
assert 'graph' in data
assert 'summary' in data
assert data['predictedPrice']['1'] is not None
assert data['predictedPrice']['7'] is not None
assert data['predictedPrice']['15'] is not None
assert data['predictedPrice']['30'] is not None
assert len(data['graph']) > 0
assert data['summary'] is not None