forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_main.py
More file actions
43 lines (32 loc) · 1.27 KB
/
Copy pathtest_main.py
File metadata and controls
43 lines (32 loc) · 1.27 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
import sys
import unittest
from pathlib import Path
try:
from fastapi.testclient import TestClient
except ModuleNotFoundError:
TestClient = None
sys.path.insert(0, str(Path(__file__).resolve().parent))
if TestClient is not None:
from main import app
@unittest.skipIf(TestClient is None, "fastapi/httpx test dependencies are not installed")
class CallUberEndpointTests(unittest.TestCase):
def setUp(self):
self.client = TestClient(app)
def test_manifest_parameters_are_json_schema_object(self):
response = self.client.get("/.well-known/omi-tools.json")
self.assertEqual(response.status_code, 200)
parameters = response.json()["tools"][0]["parameters"]
self.assertEqual(parameters["type"], "object")
self.assertIn("destination", parameters["required"])
def test_bad_geolocation_returns_400(self):
response = self.client.post(
"/api/call_uber",
json={
"destination": "SFO Airport",
"geolocation": {"latitude": "nearby", "longitude": "-122.418028"},
},
)
self.assertEqual(response.status_code, 400)
self.assertIn("could not convert string to float", response.json()["detail"])
if __name__ == "__main__":
unittest.main()