forked from weaviate/t2v-transformers-models
-
Notifications
You must be signed in to change notification settings - Fork 0
/
smoke_test.py
executable file
·41 lines (31 loc) · 1.19 KB
/
smoke_test.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
import unittest
import requests
import time
class SmokeTest(unittest.TestCase):
def _waitForStartup(self):
url = 'http://localhost:8000/.well-known/ready'
for i in range(0, 100):
try:
res = requests.get(url)
if res.status_code == 204:
return
else:
raise Exception(
"status code is {}".format(res.status_code))
except Exception as e:
print("Attempt {}: {}".format(i, e))
time.sleep(1)
raise Exception("did not start up")
def testVectorizing(self):
self._waitForStartup()
url = 'http://localhost:8000/vectors/'
req_body = {'text': 'The London Eye is a ferris wheel at the River Thames.'}
res = requests.post(url, json=req_body)
resBody = res.json()
self.assertEqual(200, res.status_code)
# below tests that what we deem a reasonable vector is returned. We are
# aware of 384 and 768 dim vectors, which should both fall in that
# range
self.assertTrue(len(resBody['vector']) > 100)
if __name__ == "__main__":
unittest.main()