"""Unit tests for ows_carveouts_python model.""" from src.models import ows_carveouts_python import pytest import httpx @pytest.mark.asyncio async def test_get_carveouts_success(ows_client_mock, mock_get_carveouts_row_1, mock_get_carveouts_row_2): """Test get_carveouts returns valid data.""" ows_client_mock.get( 'ows-carveouts-python', path='/delivery-restrictions/product/1' ).mock(return_value=httpx.Response(status_code=200, json=mock_get_carveouts_row_1)) ows_client_mock.get( 'ows-carveouts-python', path='/delivery-restrictions/product/2' ).mock(return_value=httpx.Response(status_code=200, json=mock_get_carveouts_row_2)) expected = { 1: mock_get_carveouts_row_1, 2: mock_get_carveouts_row_2, } result = await ows_carveouts_python.get_carveouts([1, 2]) assert result == expected @pytest.mark.asyncio async def test_get_carveouts_raises_exception(ows_client_mock, mock_get_carveouts_row_1): """Test get_carveouts raises exception.""" ows_client_mock.get( 'ows-carveouts-python', path='/delivery-restrictions/product/101' ).mock(return_value=httpx.Response(status_code=404, json={'code': 'not_found_error', 'messsage': None})) ows_client_mock.get( 'ows-carveouts-python', path='/delivery-restrictions/product/102' ).mock(return_value=httpx.Response(status_code=200, json=mock_get_carveouts_row_1)) with pytest.raises(Exception, match='Failed for release 101 with status 404'): await ows_carveouts_python.get_carveouts([101, 102])