-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_async_scorer.py
More file actions
51 lines (37 loc) · 1.84 KB
/
test_async_scorer.py
File metadata and controls
51 lines (37 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Comprehensive tests for async AsyncScorer class."""
from __future__ import annotations
from types import SimpleNamespace
from unittest.mock import AsyncMock
import pytest
from tests.sdk.conftest import MockScorerView
from runloop_api_client.sdk import AsyncScorer
class TestAsyncScorer:
"""Tests for AsyncScorer class."""
def test_init(self, mock_async_client: AsyncMock) -> None:
"""Test AsyncScorer initialization."""
scorer = AsyncScorer(mock_async_client, "sco_123")
assert scorer.id == "sco_123"
def test_repr(self, mock_async_client: AsyncMock) -> None:
"""Test AsyncScorer string representation."""
scorer = AsyncScorer(mock_async_client, "sco_123")
assert repr(scorer) == "<AsyncScorer id='sco_123'>"
@pytest.mark.asyncio
async def test_get_info(self, mock_async_client: AsyncMock, scorer_view: MockScorerView) -> None:
"""Test get_info method."""
mock_async_client.scenarios.scorers.retrieve = AsyncMock(return_value=scorer_view)
scorer = AsyncScorer(mock_async_client, "sco_123")
result = await scorer.get_info()
assert result == scorer_view
mock_async_client.scenarios.scorers.retrieve.assert_awaited_once()
@pytest.mark.asyncio
async def test_update(self, mock_async_client: AsyncMock) -> None:
"""Test update method."""
update_response = SimpleNamespace(id="sco_123", type="updated_scorer", bash_script="echo 'score=1.0'")
mock_async_client.scenarios.scorers.update = AsyncMock(return_value=update_response)
scorer = AsyncScorer(mock_async_client, "sco_123")
result = await scorer.update(
type="updated_scorer",
bash_script="echo 'score=1.0'",
)
assert result == update_response
mock_async_client.scenarios.scorers.update.assert_awaited_once()