-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_scorer.py
More file actions
51 lines (38 loc) · 1.71 KB
/
test_scorer.py
File metadata and controls
51 lines (38 loc) · 1.71 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 sync Scorer class."""
from __future__ import annotations
from types import SimpleNamespace
from unittest.mock import Mock
from tests.sdk.conftest import MockScorerView
from runloop_api_client.sdk import Scorer
class TestScorer:
"""Tests for Scorer class."""
def test_init(self, mock_client: Mock) -> None:
"""Test Scorer initialization."""
scorer = Scorer(mock_client, "sco_123")
assert scorer.id == "sco_123"
def test_repr(self, mock_client: Mock) -> None:
"""Test Scorer string representation."""
scorer = Scorer(mock_client, "sco_123")
assert repr(scorer) == "<Scorer id='sco_123'>"
def test_get_info(self, mock_client: Mock, scorer_view: MockScorerView) -> None:
"""Test get_info method."""
mock_client.scenarios.scorers.retrieve.return_value = scorer_view
scorer = Scorer(mock_client, "sco_123")
result = scorer.get_info()
assert result == scorer_view
mock_client.scenarios.scorers.retrieve.assert_called_once_with("sco_123")
def test_update(self, mock_client: Mock) -> None:
"""Test update method."""
update_response = SimpleNamespace(id="sco_123", type="updated_scorer", bash_script="echo 'score=1.0'")
mock_client.scenarios.scorers.update.return_value = update_response
scorer = Scorer(mock_client, "sco_123")
result = scorer.update(
type="updated_scorer",
bash_script="echo 'score=1.0'",
)
assert result == update_response
mock_client.scenarios.scorers.update.assert_called_once_with(
"sco_123",
type="updated_scorer",
bash_script="echo 'score=1.0'",
)