Skip to content
This repository has been archived by the owner on Oct 19, 2023. It is now read-only.

Commit

Permalink
test: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zac-li committed May 23, 2023
1 parent 98fe1d9 commit 74c1065
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
6 changes: 3 additions & 3 deletions tests/integration/jcloud/test_basic_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ async def _test_ws_route(app_id):
await websocket.send(json.dumps({"interval": 1}))

received_messages = []
for _ in range(5):
for _ in range(6):
message = await websocket.recv()
received_messages.append(message)

assert received_messages == ["0", "1", "2", "3", "4"]
assert received_messages[1:] == ["0", "1", "2", "3", "4"]


async def _test_workspace(app_id):
Expand All @@ -63,6 +63,6 @@ async def _test_workspace(app_id):
message = await websocket.recv()
received_messages.append(message.strip())

assert received_messages == [f"Here's string {i}" for i in range(10)]
assert received_messages[1:] == [f"Here's string {i}" for i in range(10)]
except ConnectionClosedOK:
pass
9 changes: 4 additions & 5 deletions tests/integration/jcloud/test_fastapi_app.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import json

import aiohttp
import pytest
import requests
import aiohttp

from ..helper import deploy_jcloud_fastapi_app


@pytest.mark.asyncio
async def test_basic_app():
async with deploy_jcloud_fastapi_app() as app_id:
Expand All @@ -18,9 +19,7 @@ def _test_http_route(app_id):
"accept": "application/json",
"Content-Type": "application/json",
}
response = requests.get(
f"https://{app_id}.wolf.jina.ai/status", headers=headers
)
response = requests.get(f"https://{app_id}.wolf.jina.ai/status", headers=headers)

response_data = response.json()

Expand All @@ -35,4 +34,4 @@ async def _test_ws_route(app_id):
received_messages = []
async for message in websocket:
received_messages.append(message.data)
assert received_messages == ["0", "1", "2", "3", "4"]
assert received_messages[1:] == ["0", "1", "2", "3", "4"]
16 changes: 8 additions & 8 deletions tests/integration/local/test_basic_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ async def test_basic_app_ws(run_test_app_locally, route):
await websocket.send(json.dumps({"interval": 1}))

received_messages = []
for _ in range(5):
for _ in range(6):
message = await websocket.recv()
received_messages.append(message)

assert received_messages == ["0", "1", "2", "3", "4"]
assert received_messages[1:] == ["0", "1", "2", "3", "4"]


@pytest.mark.parametrize(
Expand Down Expand Up @@ -136,11 +136,11 @@ async def test_basic_app_ws_authorized(run_test_app_locally, route):
await websocket.send(json.dumps({"interval": 1}))

received_messages = []
for _ in range(5):
for _ in range(6):
message = await websocket.recv()
received_messages.append(message)

assert received_messages == ["0", "1", "2", "3", "4"]
assert received_messages[1:] == ["0", "1", "2", "3", "4"]


@pytest.mark.parametrize(
Expand Down Expand Up @@ -284,11 +284,11 @@ async def test_metrics_ws(run_test_app_locally, route):
await websocket.send(json.dumps({"interval": 1}))

received_messages = []
for _ in range(5):
for _ in range(6):
message = await websocket.recv()
received_messages.append(message)

assert received_messages == ["0", "1", "2", "3", "4"]
assert received_messages[1:] == ["0", "1", "2", "3", "4"]

start_time = time.time()
examine_request_duration_with_retry(
Expand Down Expand Up @@ -322,8 +322,8 @@ async def test_workspace(run_test_app_locally):
await websocket.send(json.dumps({}))

received_messages = []
for _ in range(10):
for _ in range(11):
message = await websocket.recv()
received_messages.append(message.strip())

assert received_messages == [f"Here's string {i}" for i in range(10)]
assert received_messages[1:] == [f"Here's string {i}" for i in range(10)]
6 changes: 3 additions & 3 deletions tests/integration/local/test_fastapi_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async def test_websocket_endpoint(run_fastapi_app_locally, route):
received_messages = []
async for message in websocket:
received_messages.append(message.data)
assert received_messages == ["0", "1", "2", "3", "4"]
assert received_messages[1:] == ["0", "1", "2", "3", "4"]


@pytest.mark.parametrize(
Expand Down Expand Up @@ -109,11 +109,11 @@ async def test_metrics_ws(run_fastapi_app_locally, route):
await websocket.send(json.dumps({"interval": 1}))

received_messages = []
for _ in range(5):
for _ in range(6):
message = await websocket.recv()
received_messages.append(message)

assert received_messages == ["0", "1", "2", "3", "4"]
assert received_messages[1:] == ["0", "1", "2", "3", "4"]

start_time = time.time()
examine_request_duration_with_retry(
Expand Down

0 comments on commit 74c1065

Please sign in to comment.