"""Unit tests for the auto approval results logic module.""" from unittest.mock import MagicMock, patch import pytest from src import logic def test_save_auto_approval_results_succeeds_on_200() -> None: """A 200 response completes without raising.""" mock_response = MagicMock(status_code=200) with patch.object( logic.client, "post", return_value=mock_response ) as mock_post: result = logic.save_auto_approval_results(104, {"foo": "bar"}) assert result is None mock_post.assert_called_once_with( "ows-product-review", "/score/104", json={"foo": "bar"} ) def test_save_auto_approval_results_raises_on_non_200() -> None: """A non-200 response raises with the status code and body in the message.""" mock_response = MagicMock(status_code=400, text="bad request") with patch.object(logic.client, "post", return_value=mock_response): with pytest.raises(Exception, match="Status code: 400"): logic.save_auto_approval_results(104, {"foo": "bar"})