Skip to content

Commit 168180c

Browse files
committed
fix unit tests
1 parent cf5335e commit 168180c

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/tests/data/datasets/test_dataset.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pandas as pd
44
from unittest.mock import Mock, patch, mock_open
55
from judgeval.data.datasets.dataset import EvalDataset
6+
from judgeval.data.datasets.eval_dataset_client import EvalDatasetClient
67
from judgeval.data import Example
78
from judgeval.data.datasets.ground_truth import GroundTruthExample
89

@@ -38,6 +39,10 @@ def sample_ground_truth():
3839
def dataset():
3940
return EvalDataset(judgment_api_key="test_key")
4041

42+
@pytest.fixture
43+
def eval_dataset_client():
44+
return EvalDatasetClient(judgment_api_key="test_key")
45+
4146
def test_init():
4247
dataset = EvalDataset(judgment_api_key="test_key")
4348
assert dataset.judgment_api_key == "test_key"
@@ -57,7 +62,7 @@ def test_add_ground_truth(dataset, sample_ground_truth):
5762
assert dataset.ground_truths[0] == sample_ground_truth
5863

5964
@patch('requests.post')
60-
def test_push_success(mock_post, dataset, sample_example):
65+
def test_push_success(mock_post, dataset, sample_example, eval_dataset_client):
6166
# Setup mock response
6267
mock_response = Mock()
6368
mock_response.status_code = 200
@@ -66,26 +71,26 @@ def test_push_success(mock_post, dataset, sample_example):
6671

6772
# Add example and push
6873
dataset.add_example(sample_example)
69-
result = dataset.push("test_alias")
74+
result = eval_dataset_client.push(dataset, "test_alias")
7075

7176
assert result is True
7277
assert dataset._alias == "test_alias"
7378
assert dataset._id == "test_id"
7479
mock_post.assert_called_once()
7580

7681
@patch('requests.post')
77-
def test_push_server_error(mock_post, dataset):
82+
def test_push_server_error(mock_post, dataset, eval_dataset_client):
7883
mock_response = Mock()
7984
mock_response.status_code = 500
8085
mock_post.return_value = mock_response
8186

82-
result = dataset.push("test_alias")
87+
result = eval_dataset_client.push(dataset, "test_alias")
8388
assert result is False
8489

8590
mock_post.assert_called_once()
8691

8792
@patch('requests.post')
88-
def test_pull_success(mock_post, dataset):
93+
def test_pull_success(mock_post, eval_dataset_client):
8994
mock_response = Mock()
9095
mock_response.status_code = 200
9196
mock_response.json.return_value = {
@@ -96,11 +101,11 @@ def test_pull_success(mock_post, dataset):
96101
}
97102
mock_post.return_value = mock_response
98103

99-
dataset.pull("test_alias")
100-
assert len(dataset.ground_truths) == 1
101-
assert len(dataset.examples) == 1
102-
assert dataset._alias == "test_alias"
103-
assert dataset._id == "test_id"
104+
pulled_dataset = eval_dataset_client.pull("test_alias")
105+
assert len(pulled_dataset.ground_truths) == 1
106+
assert len(pulled_dataset.examples) == 1
107+
assert pulled_dataset._alias == "test_alias"
108+
assert pulled_dataset._id == "test_id"
104109

105110
@patch('builtins.open', new_callable=mock_open)
106111
def test_add_from_json(mock_file, dataset):

0 commit comments

Comments
 (0)