@@ -128,3 +128,31 @@ def test_firecrawl(self):
128
128
assert service_response .get ("success" , False ), "Firecrawl search API call failed"
129
129
assert len (service_response .get ("data" , [])) == top_k
130
130
assert "Sam" in str (service_response )
131
+
132
+ @pytest .mark .integration
133
+ @pytest .mark .skipif (not os .environ .get ("OPENAI_API_KEY" , "" ), reason = "OPENAI_API_KEY not set or empty" )
134
+ @pytest .mark .skipif (not os .environ .get ("TOMTOM_API_KEY" , "" ), reason = "TOMTOM_API_KEY not set or empty" )
135
+ def test_tomtom (self , test_files_path ):
136
+
137
+ # LLM can't accept the original operation name with {} and other special characters,
138
+ # so we need to normalize it, see normalize_operation_name in utils.py
139
+ target_operation = "search_versionNumber_categorySearch_query_ext__get"
140
+ spec = "https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/tomtom.com/search/1.0.0/openapi.yaml"
141
+ config = ClientConfig (openapi_spec = create_openapi_spec (spec ),
142
+ credentials = os .getenv ("TOMTOM_API_KEY" ),
143
+ allowed_operations = ["search_versionNumber_categorySearch_query_ext__get" ])
144
+
145
+ client = OpenAI (api_key = os .getenv ("OPENAI_API_KEY" ))
146
+ response = client .chat .completions .create (
147
+ model = "gpt-4o" ,
148
+ messages = [{"role" : "user" , "content" : "Search for pizza in San Francisco, US and don't use long/lat" }],
149
+ tools = config .get_tool_definitions (),
150
+ )
151
+ api = OpenAPIClient (config )
152
+ service_response = api .invoke (response )
153
+
154
+ # verify that we get some valid response
155
+ assert isinstance (service_response , dict )
156
+ assert "pizza" in str (service_response )
157
+ assert "summary" in str (service_response )
158
+ assert "countrySubdivisionCode" in str (service_response )
0 commit comments