"""Test carveouts_python logic.""" from typing import Any import pytest from pytest_mock import MockerFixture from video.logic import carveouts_python as carveouts_python_logic from video.models.ows import carveouts_python as ows_carveouts_python @pytest.mark.parametrize( ( "test_description", "product_id", "expected_ows_carveouts_res", "expected_response", ), [ ( "test iTunes is video carveouts for account level", 123, { "account": { "service": [ { "service_id": 1, "service_name": "iTunes/Apple", "distribution_types": [1, 3], } ], "service_country": [], "country": [], "new_service_opt_outs": [], }, "subaccount": {"service": [], "service_country": [], "country": []}, "product": { "service": [], "service_country": [], "country": [], "new_service_opt_outs": [], }, }, True, ), ( "test iTunes is video carveouts for subaccount level", 234, { "account": { "service": [], "service_country": [], "country": [], "new_service_opt_outs": [], }, "subaccount": { "service": [ { "service_id": 1, "service_name": "iTunes/Apple", "distribution_types": [], } ], "service_country": [], "country": [], }, "product": { "service": [], "service_country": [], "country": [], "new_service_opt_outs": [], }, }, True, ), ( "test iTunes is video carveouts for product level", 345, { "account": { "service": [], "service_country": [], "country": [], "new_service_opt_outs": [], }, "subaccount": {"service": [], "service_country": [], "country": []}, "product": { "service": [ { "service_id": 1, "service_name": "iTunes/Apple", "distribution_types": [1, 3], } ], "service_country": [], "country": [], "new_service_opt_outs": [], }, }, True, ), ( "test iTunes is not video carveouts", 345, { "account": { "service": [], "service_country": [], "country": [], "new_service_opt_outs": [], }, "subaccount": {"service": [], "service_country": [], "country": []}, "product": { "service": [], "service_country": [], "country": [], "new_service_opt_outs": [], }, }, False, ), ( "test iTunes is not video carveouts for account level", 123, { "account": { "service": [ { "service_id": 1, "service_name": "iTunes/Apple", "distribution_types": [1], } ], "service_country": [], "country": [], "new_service_opt_outs": [], }, "subaccount": {"service": [], "service_country": [], "country": []}, "product": { "service": [], "service_country": [], "country": [], "new_service_opt_outs": [], }, }, False, ), ], ) def test_is_itunes_carved_out( mocker: MockerFixture, test_description: Any, product_id: Any, expected_ows_carveouts_res: Any, expected_response: Any, ) -> None: """Test is iTunes store Carveouts check logic.""" mocker.patch.object( ows_carveouts_python, "get_carveouts", return_value=expected_ows_carveouts_res ) is_itunes_carved_out_response = carveouts_python_logic.is_itunes_carved_out( product_id ) assert is_itunes_carved_out_response == expected_response