Spaces:
Sleeping
Sleeping
import unittest | |
from unittest.mock import patch | |
import main_backend | |
import src.backend.manage_requests as manage_requests | |
class TestMainBackend(unittest.TestCase): | |
def test_run_auto_eval_with_pending_requests(self, mock_run_evaluation, mock_set_eval_request, | |
mock_sort_models_by_priority, mock_get_eval_requests, | |
mock_check_completed_evals): | |
mock_sort_models_by_priority.return_value = [manage_requests.EvalRequest( | |
model="test_model", | |
private=True, | |
status="PENDING", | |
json_filepath="test_filepath", | |
weight_type="test_weight_type", | |
precision="test_precision", | |
base_model="test_base_model", | |
revision="test_revision", | |
)] | |
main_backend.run_auto_eval() | |
# Assertions | |
mock_check_completed_evals.assert_called() | |
mock_get_eval_requests.assert_called() | |
mock_sort_models_by_priority.assert_called() | |
mock_set_eval_request.assert_called() | |
mock_run_evaluation.assert_called() | |
def test_run_auto_eval_with_no_pending_requests(self, mock_get_eval_requests, | |
mock_check_completed_evals, mock_print): | |
mock_get_eval_requests.return_value = [] | |
main_backend.run_auto_eval() | |
# Assertions | |
mock_check_completed_evals.assert_called() | |
mock_get_eval_requests.assert_called() | |
mock_print.assert_any_call("No eval requests found. Exiting.") | |
if __name__ == "__main__": | |
unittest.main() | |