Skip to content

Commit 565da63

Browse files
committed
Update test_fastapi.py
1 parent 559e16a commit 565da63

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

tests/test_serverless/test_modules/test_fastapi.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,18 @@ def test_start_serverless_with_realtime(self):
3030
with patch(f"{module_location}.Heartbeat.start_ping", Mock()) as mock_ping, \
3131
patch(f"{module_location}.FastAPI", Mock()) as mock_fastapi, \
3232
patch(f"{module_location}.APIRouter", return_value=Mock()) as mock_router, \
33-
patch(f"{module_location}.uvicorn", Mock()) as mock_uvicorn:
33+
patch(f"{module_location}.uvicorn", Mock()) as mock_uvicorn, \
34+
patch("runpod.serverless.os") as mock_os:
3435

3536
rp_fastapi.RUNPOD_REALTIME_PORT = '1111'
3637
rp_fastapi.RUNPOD_ENDPOINT_ID = 'test_endpoint_id'
3738

38-
os.environ["RUNPOD_REALTIME_PORT"] = '1111'
39-
os.environ["RUNPOD_ENDPOINT_ID"] = 'test_endpoint_id'
39+
# os.environ["RUNPOD_REALTIME_PORT"] = '1111'
40+
# mock return value for RUNPOD_REALTIME_PORT only
41+
mock_os.environ.get.side_effect = lambda x: '1111' if x == "RUNPOD_REALTIME_PORT" else None # pylint: disable=line-too-long
42+
43+
# os.environ["RUNPOD_ENDPOINT_ID"] = 'test_endpoint_id'
44+
mock_os.environ.get.side_effect = lambda x: 'test_endpoint_id' if x == "RUNPOD_ENDPOINT_ID" else None # pylint: disable=line-too-long
4045

4146
runpod.serverless.start({"handler": self.handler})
4247

0 commit comments

Comments
 (0)