"""Test for ows-product-digital model.""" from models import ows_product_digital import pytest from models.api_exceptions import PersistentException def test_get_digital_product_info_success( mocker, digital_product_info_success_response, product_id, digital_product_fixture): """Test get_digital_product_info from ows-product-digital.""" mocker.patch( 'requests.get', return_value=digital_product_info_success_response) result = ows_product_digital.get_digital_product_info(product_id) assert result == digital_product_fixture def test_get_digital_product_info_error( mocker, ows_error_response, product_id): """Test get_digital_product_info from ows-product-digital error.""" mocker.patch('requests.get', return_value=ows_error_response) with pytest.raises(PersistentException): ows_product_digital.get_digital_product_info(product_id) def test_get_digital_product_info_not_found( mocker, ows_not_found_response, product_id): """Test get_digital_product_info from ows-product-digital not found.""" mocker.patch('requests.get', return_value=ows_not_found_response) with pytest.raises(PersistentException): ows_product_digital.get_digital_product_info(product_id) def test_update_digital_product_info_empty_product_artists( mocker, digital_product_info_success_response, digital_product_fixture, product_id): """Test empty update_digital_product_info from ows-product-digital.""" mocker.patch( 'requests.put', return_value=digital_product_info_success_response) result = ows_product_digital.update_digital_product_info( {'product_id': product_id, 'product_artists': []}) assert result == digital_product_fixture def test_update_digital_product_info_error( mocker, ows_error_response, digital_product_fixture): """Test update_digital_product_info from ows-product-digital error.""" mocker.patch('requests.put', return_value=ows_error_response) with pytest.raises(PersistentException): ows_product_digital.update_digital_product_info( digital_product_fixture)