Skip to content

Commit 6d2b499

Browse files
chore(internal): update jsonl tests
1 parent 026cf87 commit 6d2b499

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

tests/api_resources/test_events.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from gitpod.types import EventListResponse, EventWatchResponse
1313
from gitpod._utils import parse_datetime
1414
from gitpod.pagination import SyncEntriesPage, AsyncEntriesPage
15-
from gitpod._decoders.jsonl import JSONLDecoder, AsyncJSONLDecoder
1615

1716
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
1817

@@ -73,7 +72,8 @@ def test_streaming_response_list(self, client: Gitpod) -> None:
7372
@parametrize
7473
def test_method_watch(self, client: Gitpod) -> None:
7574
event_stream = client.events.watch()
76-
assert_matches_type(JSONLDecoder[EventWatchResponse], event_stream, path=["response"])
75+
for item in event_stream:
76+
assert_matches_type(EventWatchResponse, item, path=["response"])
7777

7878
@pytest.mark.skip(reason="Mock server tests are disabled")
7979
@parametrize
@@ -82,7 +82,8 @@ def test_method_watch_with_all_params(self, client: Gitpod) -> None:
8282
environment_id="environmentId",
8383
organization=True,
8484
)
85-
assert_matches_type(JSONLDecoder[EventWatchResponse], event_stream, path=["response"])
85+
for item in event_stream:
86+
assert_matches_type(EventWatchResponse, item, path=["response"])
8687

8788
@pytest.mark.skip(reason="Mock server tests are disabled")
8889
@parametrize
@@ -91,7 +92,8 @@ def test_raw_response_watch(self, client: Gitpod) -> None:
9192

9293
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
9394
stream = response.parse()
94-
stream.close()
95+
for item in stream:
96+
assert_matches_type(EventWatchResponse, item, path=["line"])
9597

9698
@pytest.mark.skip(reason="Mock server tests are disabled")
9799
@parametrize
@@ -101,7 +103,8 @@ def test_streaming_response_watch(self, client: Gitpod) -> None:
101103
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
102104

103105
stream = response.parse()
104-
stream.close()
106+
for item in stream:
107+
assert_matches_type(EventWatchResponse, item, path=["item"])
105108

106109
assert cast(Any, response.is_closed) is True
107110

@@ -164,7 +167,8 @@ async def test_streaming_response_list(self, async_client: AsyncGitpod) -> None:
164167
@parametrize
165168
async def test_method_watch(self, async_client: AsyncGitpod) -> None:
166169
event_stream = await async_client.events.watch()
167-
assert_matches_type(AsyncJSONLDecoder[EventWatchResponse], event_stream, path=["response"])
170+
async for item in event_stream:
171+
assert_matches_type(EventWatchResponse, item, path=["response"])
168172

169173
@pytest.mark.skip(reason="Mock server tests are disabled")
170174
@parametrize
@@ -173,7 +177,8 @@ async def test_method_watch_with_all_params(self, async_client: AsyncGitpod) ->
173177
environment_id="environmentId",
174178
organization=True,
175179
)
176-
assert_matches_type(AsyncJSONLDecoder[EventWatchResponse], event_stream, path=["response"])
180+
async for item in event_stream:
181+
assert_matches_type(EventWatchResponse, item, path=["response"])
177182

178183
@pytest.mark.skip(reason="Mock server tests are disabled")
179184
@parametrize
@@ -182,7 +187,8 @@ async def test_raw_response_watch(self, async_client: AsyncGitpod) -> None:
182187

183188
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
184189
stream = await response.parse()
185-
await stream.close()
190+
async for item in stream:
191+
assert_matches_type(EventWatchResponse, item, path=["line"])
186192

187193
@pytest.mark.skip(reason="Mock server tests are disabled")
188194
@parametrize
@@ -192,6 +198,7 @@ async def test_streaming_response_watch(self, async_client: AsyncGitpod) -> None
192198
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
193199

194200
stream = await response.parse()
195-
await stream.close()
201+
async for item in stream:
202+
assert_matches_type(EventWatchResponse, item, path=["item"])
196203

197204
assert cast(Any, response.is_closed) is True

0 commit comments

Comments
 (0)