Skip to content

Commit

Permalink
updates async job tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BWMac committed Jan 15, 2025
1 parent 3360390 commit 40842b2
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions tests/unit/synapseclient/mixins/async/unit_test_asynchronous_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

from synapseclient.core.constants.concrete_types import AGENT_CHAT_REQUEST

from unittest.mock import patch
from unittest.mock import patch, AsyncMock


class TestSendJobAsync:
Expand Down Expand Up @@ -59,12 +59,13 @@ async def test_send_job_async_when_request_is_invalid_concrete_type(self) -> Non

async def test_send_job_async_when_request_is_valid(self) -> None:
with (
patch.object(
Synapse, "get_client", return_value=self.syn
patch(
"synapseclient.Synapse.get_client",
return_value=self.syn,
) as mock_get_client,
patch.object(
Synapse,
"rest_post_async",
patch(
"synapseclient.Synapse.rest_post_async",
new_callable=AsyncMock,
return_value={"token": "123"},
) as mock_rest_post_async,
):
Expand Down Expand Up @@ -111,9 +112,9 @@ def init_syn(self, syn: Synapse) -> None:

async def test_get_job_async_when_job_fails(self) -> None:
with (
patch.object(
Synapse,
"rest_get_async",
patch(
"synapseclient.Synapse.rest_get_async",
new_callable=AsyncMock,
return_value={},
) as mock_rest_get_async,
patch.object(
Expand Down Expand Up @@ -149,9 +150,9 @@ async def test_get_job_async_when_job_fails(self) -> None:

async def test_get_job_async_when_job_times_out(self) -> None:
with (
patch.object(
Synapse,
"rest_get_async",
patch(
"synapseclient.Synapse.rest_get_async",
new_callable=AsyncMock,
return_value={},
) as mock_rest_get_async,
patch.object(
Expand Down Expand Up @@ -193,14 +194,14 @@ def init_syn(self, syn: Synapse) -> None:

async def test_send_job_and_wait_async(self) -> None:
with (
patch.object(
asynchronous_job,
"send_job_async",
patch(
"synapseclient.models.mixins.asynchronous_job.send_job_async",
new_callable=AsyncMock,
return_value=self.job_id,
) as mock_send_job_async,
patch.object(
asynchronous_job,
"get_job_async",
patch(
"synapseclient.models.mixins.asynchronous_job.get_job_async",
new_callable=AsyncMock,
return_value={
"key": "value",
},
Expand Down

0 comments on commit 40842b2

Please sign in to comment.