From f4462d1ed50eb0f47070c2c87f2a22493dbe34bc Mon Sep 17 00:00:00 2001 From: Adil Hafeez Date: Fri, 14 Mar 2025 17:27:35 -0700 Subject: [PATCH] add tests --- .../currency_exchange/hurl_tests/simple.hurl | 19 +++++++++++++++++++ .../hurl_tests/simple_stream.hurl | 17 +++++++++++++++++ .../weather_forecast/hurl_tests/simple.hurl | 19 +++++++++++++++++++ .../hurl_tests/simple_stream.hurl | 17 +++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 demos/samples_python/currency_exchange/hurl_tests/simple.hurl create mode 100644 demos/samples_python/currency_exchange/hurl_tests/simple_stream.hurl create mode 100644 demos/samples_python/weather_forecast/hurl_tests/simple.hurl create mode 100644 demos/samples_python/weather_forecast/hurl_tests/simple_stream.hurl diff --git a/demos/samples_python/currency_exchange/hurl_tests/simple.hurl b/demos/samples_python/currency_exchange/hurl_tests/simple.hurl new file mode 100644 index 00000000..579de34a --- /dev/null +++ b/demos/samples_python/currency_exchange/hurl_tests/simple.hurl @@ -0,0 +1,19 @@ +POST http://localhost:10000/v1/chat/completions +Content-Type: application/json + +{ + "messages": [ + { + "role": "user", + "content": "convert 100 eur" + } + ] +} +HTTP 200 +[Asserts] +header "content-type" == "application/json" +jsonpath "$.model" matches /^gpt-4o/ +jsonpath "$.metadata.x-arch-state" != null +jsonpath "$.usage" != null +jsonpath "$.choices[0].message.content" != null +jsonpath "$.choices[0].message.role" == "assistant" diff --git a/demos/samples_python/currency_exchange/hurl_tests/simple_stream.hurl b/demos/samples_python/currency_exchange/hurl_tests/simple_stream.hurl new file mode 100644 index 00000000..8315236c --- /dev/null +++ b/demos/samples_python/currency_exchange/hurl_tests/simple_stream.hurl @@ -0,0 +1,17 @@ +POST http://localhost:10000/v1/chat/completions +Content-Type: application/json + +{ + "messages": [ + { + "role": "user", + "content": "convert 100 eur" + } + ], + "stream": true +} +HTTP 200 +[Asserts] +header "content-type" matches /text\/event-stream/ +body matches /^data: .*?currency_exchange.*?\n/ +body matches /^data: .*?EUR.*?\n/ diff --git a/demos/samples_python/weather_forecast/hurl_tests/simple.hurl b/demos/samples_python/weather_forecast/hurl_tests/simple.hurl new file mode 100644 index 00000000..d1243d20 --- /dev/null +++ b/demos/samples_python/weather_forecast/hurl_tests/simple.hurl @@ -0,0 +1,19 @@ +POST http://localhost:10000/v1/chat/completions +Content-Type: application/json + +{ + "messages": [ + { + "role": "user", + "content": "how is the weather in seattle for next 5 days" + } + ] +} +HTTP 200 +[Asserts] +header "content-type" == "application/json" +jsonpath "$.model" matches /^gpt-4o/ +jsonpath "$.metadata.x-arch-state" != null +jsonpath "$.usage" != null +jsonpath "$.choices[0].message.content" matches /Seattle/ +jsonpath "$.choices[0].message.role" == "assistant" diff --git a/demos/samples_python/weather_forecast/hurl_tests/simple_stream.hurl b/demos/samples_python/weather_forecast/hurl_tests/simple_stream.hurl new file mode 100644 index 00000000..51844c2d --- /dev/null +++ b/demos/samples_python/weather_forecast/hurl_tests/simple_stream.hurl @@ -0,0 +1,17 @@ +POST http://localhost:10000/v1/chat/completions +Content-Type: application/json + +{ + "messages": [ + { + "role": "user", + "content": "how is the weather in seattle for next 5 days" + } + ], + "stream": true +} +HTTP 200 +[Asserts] +header "content-type" matches /text\/event-stream/ +body matches "(?s).*\"name\":\"get_current_weather\".*" +body matches "(?s).*\"model\":\"gpt-4o-mini.*"