Skip to content

Commit 29d5c77

Browse files
refactor(tests): switch from prism to steady
1 parent 5615d9e commit 29d5c77

23 files changed

Lines changed: 22 additions & 782 deletions

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=brackets --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=brackets --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=brackets --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/channels/test_bulk.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
class TestBulk:
1919
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
2020

21-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
2221
@parametrize
2322
def test_method_update_message_status(self, client: Knock) -> None:
2423
bulk = client.channels.bulk.update_message_status(
@@ -27,7 +26,6 @@ def test_method_update_message_status(self, client: Knock) -> None:
2726
)
2827
assert_matches_type(BulkOperation, bulk, path=["response"])
2928

30-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
3129
@parametrize
3230
def test_method_update_message_status_with_all_params(self, client: Knock) -> None:
3331
bulk = client.channels.bulk.update_message_status(
@@ -46,7 +44,6 @@ def test_method_update_message_status_with_all_params(self, client: Knock) -> No
4644
)
4745
assert_matches_type(BulkOperation, bulk, path=["response"])
4846

49-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
5047
@parametrize
5148
def test_raw_response_update_message_status(self, client: Knock) -> None:
5249
response = client.channels.bulk.with_raw_response.update_message_status(
@@ -59,7 +56,6 @@ def test_raw_response_update_message_status(self, client: Knock) -> None:
5956
bulk = response.parse()
6057
assert_matches_type(BulkOperation, bulk, path=["response"])
6158

62-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
6359
@parametrize
6460
def test_streaming_response_update_message_status(self, client: Knock) -> None:
6561
with client.channels.bulk.with_streaming_response.update_message_status(
@@ -74,7 +70,6 @@ def test_streaming_response_update_message_status(self, client: Knock) -> None:
7470

7571
assert cast(Any, response.is_closed) is True
7672

77-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
7873
@parametrize
7974
def test_path_params_update_message_status(self, client: Knock) -> None:
8075
with pytest.raises(ValueError, match=r"Expected a non-empty value for `channel_id` but received ''"):
@@ -89,7 +84,6 @@ class TestAsyncBulk:
8984
"async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"]
9085
)
9186

92-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
9387
@parametrize
9488
async def test_method_update_message_status(self, async_client: AsyncKnock) -> None:
9589
bulk = await async_client.channels.bulk.update_message_status(
@@ -98,7 +92,6 @@ async def test_method_update_message_status(self, async_client: AsyncKnock) -> N
9892
)
9993
assert_matches_type(BulkOperation, bulk, path=["response"])
10094

101-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
10295
@parametrize
10396
async def test_method_update_message_status_with_all_params(self, async_client: AsyncKnock) -> None:
10497
bulk = await async_client.channels.bulk.update_message_status(
@@ -117,7 +110,6 @@ async def test_method_update_message_status_with_all_params(self, async_client:
117110
)
118111
assert_matches_type(BulkOperation, bulk, path=["response"])
119112

120-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
121113
@parametrize
122114
async def test_raw_response_update_message_status(self, async_client: AsyncKnock) -> None:
123115
response = await async_client.channels.bulk.with_raw_response.update_message_status(
@@ -130,7 +122,6 @@ async def test_raw_response_update_message_status(self, async_client: AsyncKnock
130122
bulk = await response.parse()
131123
assert_matches_type(BulkOperation, bulk, path=["response"])
132124

133-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
134125
@parametrize
135126
async def test_streaming_response_update_message_status(self, async_client: AsyncKnock) -> None:
136127
async with async_client.channels.bulk.with_streaming_response.update_message_status(
@@ -145,7 +136,6 @@ async def test_streaming_response_update_message_status(self, async_client: Asyn
145136

146137
assert cast(Any, response.is_closed) is True
147138

148-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
149139
@parametrize
150140
async def test_path_params_update_message_status(self, async_client: AsyncKnock) -> None:
151141
with pytest.raises(ValueError, match=r"Expected a non-empty value for `channel_id` but received ''"):

tests/api_resources/integrations/test_census.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
class TestCensus:
1818
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
1919

20-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
2120
@parametrize
2221
def test_method_custom_destination(self, client: Knock) -> None:
2322
census = client.integrations.census.custom_destination(
@@ -27,7 +26,6 @@ def test_method_custom_destination(self, client: Knock) -> None:
2726
)
2827
assert_matches_type(CensusCustomDestinationResponse, census, path=["response"])
2928

30-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
3129
@parametrize
3230
def test_method_custom_destination_with_all_params(self, client: Knock) -> None:
3331
census = client.integrations.census.custom_destination(
@@ -38,7 +36,6 @@ def test_method_custom_destination_with_all_params(self, client: Knock) -> None:
3836
)
3937
assert_matches_type(CensusCustomDestinationResponse, census, path=["response"])
4038

41-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
4239
@parametrize
4340
def test_raw_response_custom_destination(self, client: Knock) -> None:
4441
response = client.integrations.census.with_raw_response.custom_destination(
@@ -52,7 +49,6 @@ def test_raw_response_custom_destination(self, client: Knock) -> None:
5249
census = response.parse()
5350
assert_matches_type(CensusCustomDestinationResponse, census, path=["response"])
5451

55-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
5652
@parametrize
5753
def test_streaming_response_custom_destination(self, client: Knock) -> None:
5854
with client.integrations.census.with_streaming_response.custom_destination(
@@ -74,7 +70,6 @@ class TestAsyncCensus:
7470
"async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"]
7571
)
7672

77-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
7873
@parametrize
7974
async def test_method_custom_destination(self, async_client: AsyncKnock) -> None:
8075
census = await async_client.integrations.census.custom_destination(
@@ -84,7 +79,6 @@ async def test_method_custom_destination(self, async_client: AsyncKnock) -> None
8479
)
8580
assert_matches_type(CensusCustomDestinationResponse, census, path=["response"])
8681

87-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
8882
@parametrize
8983
async def test_method_custom_destination_with_all_params(self, async_client: AsyncKnock) -> None:
9084
census = await async_client.integrations.census.custom_destination(
@@ -95,7 +89,6 @@ async def test_method_custom_destination_with_all_params(self, async_client: Asy
9589
)
9690
assert_matches_type(CensusCustomDestinationResponse, census, path=["response"])
9791

98-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
9992
@parametrize
10093
async def test_raw_response_custom_destination(self, async_client: AsyncKnock) -> None:
10194
response = await async_client.integrations.census.with_raw_response.custom_destination(
@@ -109,7 +102,6 @@ async def test_raw_response_custom_destination(self, async_client: AsyncKnock) -
109102
census = await response.parse()
110103
assert_matches_type(CensusCustomDestinationResponse, census, path=["response"])
111104

112-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
113105
@parametrize
114106
async def test_streaming_response_custom_destination(self, async_client: AsyncKnock) -> None:
115107
async with async_client.integrations.census.with_streaming_response.custom_destination(

tests/api_resources/integrations/test_hightouch.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
class TestHightouch:
1818
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
1919

20-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
2120
@parametrize
2221
def test_method_embedded_destination(self, client: Knock) -> None:
2322
hightouch = client.integrations.hightouch.embedded_destination(
@@ -27,7 +26,6 @@ def test_method_embedded_destination(self, client: Knock) -> None:
2726
)
2827
assert_matches_type(HightouchEmbeddedDestinationResponse, hightouch, path=["response"])
2928

30-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
3129
@parametrize
3230
def test_method_embedded_destination_with_all_params(self, client: Knock) -> None:
3331
hightouch = client.integrations.hightouch.embedded_destination(
@@ -38,7 +36,6 @@ def test_method_embedded_destination_with_all_params(self, client: Knock) -> Non
3836
)
3937
assert_matches_type(HightouchEmbeddedDestinationResponse, hightouch, path=["response"])
4038

41-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
4239
@parametrize
4340
def test_raw_response_embedded_destination(self, client: Knock) -> None:
4441
response = client.integrations.hightouch.with_raw_response.embedded_destination(
@@ -52,7 +49,6 @@ def test_raw_response_embedded_destination(self, client: Knock) -> None:
5249
hightouch = response.parse()
5350
assert_matches_type(HightouchEmbeddedDestinationResponse, hightouch, path=["response"])
5451

55-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
5652
@parametrize
5753
def test_streaming_response_embedded_destination(self, client: Knock) -> None:
5854
with client.integrations.hightouch.with_streaming_response.embedded_destination(
@@ -74,7 +70,6 @@ class TestAsyncHightouch:
7470
"async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"]
7571
)
7672

77-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
7873
@parametrize
7974
async def test_method_embedded_destination(self, async_client: AsyncKnock) -> None:
8075
hightouch = await async_client.integrations.hightouch.embedded_destination(
@@ -84,7 +79,6 @@ async def test_method_embedded_destination(self, async_client: AsyncKnock) -> No
8479
)
8580
assert_matches_type(HightouchEmbeddedDestinationResponse, hightouch, path=["response"])
8681

87-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
8882
@parametrize
8983
async def test_method_embedded_destination_with_all_params(self, async_client: AsyncKnock) -> None:
9084
hightouch = await async_client.integrations.hightouch.embedded_destination(
@@ -95,7 +89,6 @@ async def test_method_embedded_destination_with_all_params(self, async_client: A
9589
)
9690
assert_matches_type(HightouchEmbeddedDestinationResponse, hightouch, path=["response"])
9791

98-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
9992
@parametrize
10093
async def test_raw_response_embedded_destination(self, async_client: AsyncKnock) -> None:
10194
response = await async_client.integrations.hightouch.with_raw_response.embedded_destination(
@@ -109,7 +102,6 @@ async def test_raw_response_embedded_destination(self, async_client: AsyncKnock)
109102
hightouch = await response.parse()
110103
assert_matches_type(HightouchEmbeddedDestinationResponse, hightouch, path=["response"])
111104

112-
@pytest.mark.skip(reason="Mock server doesn't support callbacks yet")
113105
@parametrize
114106
async def test_streaming_response_embedded_destination(self, async_client: AsyncKnock) -> None:
115107
async with async_client.integrations.hightouch.with_streaming_response.embedded_destination(

0 commit comments

Comments
 (0)