"""Unit tests for ows-product model.""" import pytest from src.model import ows_product class TestGetProduct: """Tests for get_product function.""" @pytest.fixture def get_ows_product_url_mock(self, mocker): """Mock _get_ows_product_url function.""" return mocker.patch.object(ows_product, '_get_ows_product_url') @pytest.fixture def product_id(self): """Product id.""" return 2810803 @pytest.fixture def requests_get_mock(self, mocker): """Mock requests get method.""" return mocker.patch('requests.get') def test_get_product(self, get_ows_product_url_mock, requests_get_mock, product_id): """Test get_product function.""" # mocks url_mock = get_ows_product_url_mock.return_value response_mock = requests_get_mock.return_value # test call result = ows_product.get_product(product_id) # checks get_ows_product_url_mock.assert_called_once_with(product_id) requests_get_mock.assert_called_once_with(url_mock) assert response_mock.raise_for_status.called assert result == response_mock.json.return_value