Skip to content

Commit 032745e

Browse files
refactor(tests): switch from prism to steady
1 parent 5931597 commit 032745e

6 files changed

Lines changed: 22 additions & 60 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ $ pip install ./path-to-wheel-file.whl
8585

8686
## Running tests
8787

88-
Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.
88+
Most tests require you to [set up a mock server](https://github.com/dgellow/steady) against the OpenAPI spec to run the tests.
8989

9090
```sh
9191
$ ./scripts/mock

scripts/mock

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,34 @@ fi
1919

2020
echo "==> Starting mock server with URL ${URL}"
2121

22-
# Run prism mock on the given spec
22+
# Run steady mock on the given spec
2323
if [ "$1" == "--daemon" ]; then
2424
# Pre-install the package so the download doesn't eat into the startup timeout
25-
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism --version
25+
npm exec --package=@stdy/cli@0.19.3 -- steady --version
2626

27-
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log &
27+
npm exec --package=@stdy/cli@0.19.3 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-query-object-format=brackets "$URL" &> .stdy.log &
2828

29-
# Wait for server to come online (max 30s)
29+
# Wait for server to come online via health endpoint (max 30s)
3030
echo -n "Waiting for server"
3131
attempts=0
32-
while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do
32+
while ! curl --silent --fail "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1; do
33+
if ! kill -0 $! 2>/dev/null; then
34+
echo
35+
cat .stdy.log
36+
exit 1
37+
fi
3338
attempts=$((attempts + 1))
3439
if [ "$attempts" -ge 300 ]; then
3540
echo
36-
echo "Timed out waiting for Prism server to start"
37-
cat .prism.log
41+
echo "Timed out waiting for Steady server to start"
42+
cat .stdy.log
3843
exit 1
3944
fi
4045
echo -n "."
4146
sleep 0.1
4247
done
4348

44-
if grep -q "✖ fatal" ".prism.log"; then
45-
cat .prism.log
46-
exit 1
47-
fi
48-
4949
echo
5050
else
51-
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL"
51+
npm exec --package=@stdy/cli@0.19.3 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-query-object-format=brackets "$URL"
5252
fi

scripts/test

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ GREEN='\033[0;32m'
99
YELLOW='\033[0;33m'
1010
NC='\033[0m' # No Color
1111

12-
function prism_is_running() {
13-
curl --silent "http://localhost:4010" >/dev/null 2>&1
12+
function steady_is_running() {
13+
curl --silent "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1
1414
}
1515

1616
kill_server_on_port() {
@@ -25,7 +25,7 @@ function is_overriding_api_base_url() {
2525
[ -n "$TEST_API_BASE_URL" ]
2626
}
2727

28-
if ! is_overriding_api_base_url && ! prism_is_running ; then
28+
if ! is_overriding_api_base_url && ! steady_is_running ; then
2929
# When we exit this script, make sure to kill the background mock server process
3030
trap 'kill_server_on_port 4010' EXIT
3131

@@ -36,19 +36,19 @@ fi
3636
if is_overriding_api_base_url ; then
3737
echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}"
3838
echo
39-
elif ! prism_is_running ; then
40-
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server"
39+
elif ! steady_is_running ; then
40+
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Steady server"
4141
echo -e "running against your OpenAPI spec."
4242
echo
4343
echo -e "To run the server, pass in the path or url of your OpenAPI"
44-
echo -e "spec to the prism command:"
44+
echo -e "spec to the steady command:"
4545
echo
46-
echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}"
46+
echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.3 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-query-object-format=brackets${NC}"
4747
echo
4848

4949
exit 1
5050
else
51-
echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}"
51+
echo -e "${GREEN}✔ Mock steady server is running with your OpenAPI spec${NC}"
5252
echo
5353
fi
5454

tests/api_resources/beta/test_findall.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -296,15 +296,13 @@ def test_path_params_enrich(self, client: Parallel) -> None:
296296
},
297297
)
298298

299-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
300299
@parametrize
301300
def test_method_events(self, client: Parallel) -> None:
302301
findall_stream = client.beta.findall.events(
303302
findall_id="findall_id",
304303
)
305304
findall_stream.response.close()
306305

307-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
308306
@parametrize
309307
def test_method_events_with_all_params(self, client: Parallel) -> None:
310308
findall_stream = client.beta.findall.events(
@@ -315,7 +313,6 @@ def test_method_events_with_all_params(self, client: Parallel) -> None:
315313
)
316314
findall_stream.response.close()
317315

318-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
319316
@parametrize
320317
def test_raw_response_events(self, client: Parallel) -> None:
321318
response = client.beta.findall.with_raw_response.events(
@@ -326,7 +323,6 @@ def test_raw_response_events(self, client: Parallel) -> None:
326323
stream = response.parse()
327324
stream.close()
328325

329-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
330326
@parametrize
331327
def test_streaming_response_events(self, client: Parallel) -> None:
332328
with client.beta.findall.with_streaming_response.events(
@@ -340,7 +336,6 @@ def test_streaming_response_events(self, client: Parallel) -> None:
340336

341337
assert cast(Any, response.is_closed) is True
342338

343-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
344339
@parametrize
345340
def test_path_params_events(self, client: Parallel) -> None:
346341
with pytest.raises(ValueError, match=r"Expected a non-empty value for `findall_id` but received ''"):
@@ -811,15 +806,13 @@ async def test_path_params_enrich(self, async_client: AsyncParallel) -> None:
811806
},
812807
)
813808

814-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
815809
@parametrize
816810
async def test_method_events(self, async_client: AsyncParallel) -> None:
817811
findall_stream = await async_client.beta.findall.events(
818812
findall_id="findall_id",
819813
)
820814
await findall_stream.response.aclose()
821815

822-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
823816
@parametrize
824817
async def test_method_events_with_all_params(self, async_client: AsyncParallel) -> None:
825818
findall_stream = await async_client.beta.findall.events(
@@ -830,7 +823,6 @@ async def test_method_events_with_all_params(self, async_client: AsyncParallel)
830823
)
831824
await findall_stream.response.aclose()
832825

833-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
834826
@parametrize
835827
async def test_raw_response_events(self, async_client: AsyncParallel) -> None:
836828
response = await async_client.beta.findall.with_raw_response.events(
@@ -841,7 +833,6 @@ async def test_raw_response_events(self, async_client: AsyncParallel) -> None:
841833
stream = await response.parse()
842834
await stream.close()
843835

844-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
845836
@parametrize
846837
async def test_streaming_response_events(self, async_client: AsyncParallel) -> None:
847838
async with async_client.beta.findall.with_streaming_response.events(
@@ -855,7 +846,6 @@ async def test_streaming_response_events(self, async_client: AsyncParallel) -> N
855846

856847
assert cast(Any, response.is_closed) is True
857848

858-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
859849
@parametrize
860850
async def test_path_params_events(self, async_client: AsyncParallel) -> None:
861851
with pytest.raises(ValueError, match=r"Expected a non-empty value for `findall_id` but received ''"):

tests/api_resources/beta/test_task_group.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,13 @@ def test_path_params_add_runs(self, client: Parallel) -> None:
212212
],
213213
)
214214

215-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
216215
@parametrize
217216
def test_method_events(self, client: Parallel) -> None:
218217
task_group_stream = client.beta.task_group.events(
219218
task_group_id="taskgroup_id",
220219
)
221220
task_group_stream.response.close()
222221

223-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
224222
@parametrize
225223
def test_method_events_with_all_params(self, client: Parallel) -> None:
226224
task_group_stream = client.beta.task_group.events(
@@ -230,7 +228,6 @@ def test_method_events_with_all_params(self, client: Parallel) -> None:
230228
)
231229
task_group_stream.response.close()
232230

233-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
234231
@parametrize
235232
def test_raw_response_events(self, client: Parallel) -> None:
236233
response = client.beta.task_group.with_raw_response.events(
@@ -241,7 +238,6 @@ def test_raw_response_events(self, client: Parallel) -> None:
241238
stream = response.parse()
242239
stream.close()
243240

244-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
245241
@parametrize
246242
def test_streaming_response_events(self, client: Parallel) -> None:
247243
with client.beta.task_group.with_streaming_response.events(
@@ -255,23 +251,20 @@ def test_streaming_response_events(self, client: Parallel) -> None:
255251

256252
assert cast(Any, response.is_closed) is True
257253

258-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
259254
@parametrize
260255
def test_path_params_events(self, client: Parallel) -> None:
261256
with pytest.raises(ValueError, match=r"Expected a non-empty value for `task_group_id` but received ''"):
262257
client.beta.task_group.with_raw_response.events(
263258
task_group_id="",
264259
)
265260

266-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
267261
@parametrize
268262
def test_method_get_runs(self, client: Parallel) -> None:
269263
task_group_stream = client.beta.task_group.get_runs(
270264
task_group_id="taskgroup_id",
271265
)
272266
task_group_stream.response.close()
273267

274-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
275268
@parametrize
276269
def test_method_get_runs_with_all_params(self, client: Parallel) -> None:
277270
task_group_stream = client.beta.task_group.get_runs(
@@ -283,7 +276,6 @@ def test_method_get_runs_with_all_params(self, client: Parallel) -> None:
283276
)
284277
task_group_stream.response.close()
285278

286-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
287279
@parametrize
288280
def test_raw_response_get_runs(self, client: Parallel) -> None:
289281
response = client.beta.task_group.with_raw_response.get_runs(
@@ -294,7 +286,6 @@ def test_raw_response_get_runs(self, client: Parallel) -> None:
294286
stream = response.parse()
295287
stream.close()
296288

297-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
298289
@parametrize
299290
def test_streaming_response_get_runs(self, client: Parallel) -> None:
300291
with client.beta.task_group.with_streaming_response.get_runs(
@@ -308,7 +299,6 @@ def test_streaming_response_get_runs(self, client: Parallel) -> None:
308299

309300
assert cast(Any, response.is_closed) is True
310301

311-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
312302
@parametrize
313303
def test_path_params_get_runs(self, client: Parallel) -> None:
314304
with pytest.raises(ValueError, match=r"Expected a non-empty value for `task_group_id` but received ''"):
@@ -513,15 +503,13 @@ async def test_path_params_add_runs(self, async_client: AsyncParallel) -> None:
513503
],
514504
)
515505

516-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
517506
@parametrize
518507
async def test_method_events(self, async_client: AsyncParallel) -> None:
519508
task_group_stream = await async_client.beta.task_group.events(
520509
task_group_id="taskgroup_id",
521510
)
522511
await task_group_stream.response.aclose()
523512

524-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
525513
@parametrize
526514
async def test_method_events_with_all_params(self, async_client: AsyncParallel) -> None:
527515
task_group_stream = await async_client.beta.task_group.events(
@@ -531,7 +519,6 @@ async def test_method_events_with_all_params(self, async_client: AsyncParallel)
531519
)
532520
await task_group_stream.response.aclose()
533521

534-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
535522
@parametrize
536523
async def test_raw_response_events(self, async_client: AsyncParallel) -> None:
537524
response = await async_client.beta.task_group.with_raw_response.events(
@@ -542,7 +529,6 @@ async def test_raw_response_events(self, async_client: AsyncParallel) -> None:
542529
stream = await response.parse()
543530
await stream.close()
544531

545-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
546532
@parametrize
547533
async def test_streaming_response_events(self, async_client: AsyncParallel) -> None:
548534
async with async_client.beta.task_group.with_streaming_response.events(
@@ -556,23 +542,20 @@ async def test_streaming_response_events(self, async_client: AsyncParallel) -> N
556542

557543
assert cast(Any, response.is_closed) is True
558544

559-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
560545
@parametrize
561546
async def test_path_params_events(self, async_client: AsyncParallel) -> None:
562547
with pytest.raises(ValueError, match=r"Expected a non-empty value for `task_group_id` but received ''"):
563548
await async_client.beta.task_group.with_raw_response.events(
564549
task_group_id="",
565550
)
566551

567-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
568552
@parametrize
569553
async def test_method_get_runs(self, async_client: AsyncParallel) -> None:
570554
task_group_stream = await async_client.beta.task_group.get_runs(
571555
task_group_id="taskgroup_id",
572556
)
573557
await task_group_stream.response.aclose()
574558

575-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
576559
@parametrize
577560
async def test_method_get_runs_with_all_params(self, async_client: AsyncParallel) -> None:
578561
task_group_stream = await async_client.beta.task_group.get_runs(
@@ -584,7 +567,6 @@ async def test_method_get_runs_with_all_params(self, async_client: AsyncParallel
584567
)
585568
await task_group_stream.response.aclose()
586569

587-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
588570
@parametrize
589571
async def test_raw_response_get_runs(self, async_client: AsyncParallel) -> None:
590572
response = await async_client.beta.task_group.with_raw_response.get_runs(
@@ -595,7 +577,6 @@ async def test_raw_response_get_runs(self, async_client: AsyncParallel) -> None:
595577
stream = await response.parse()
596578
await stream.close()
597579

598-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
599580
@parametrize
600581
async def test_streaming_response_get_runs(self, async_client: AsyncParallel) -> None:
601582
async with async_client.beta.task_group.with_streaming_response.get_runs(
@@ -609,7 +590,6 @@ async def test_streaming_response_get_runs(self, async_client: AsyncParallel) ->
609590

610591
assert cast(Any, response.is_closed) is True
611592

612-
@pytest.mark.skip(reason="Mock server doesn't support text/event-stream responses")
613593
@parametrize
614594
async def test_path_params_get_runs(self, async_client: AsyncParallel) -> None:
615595
with pytest.raises(ValueError, match=r"Expected a non-empty value for `task_group_id` but received ''"):

0 commit comments

Comments
 (0)