|  | 
|  | 1 | +import httpx | 
|  | 2 | +import pytest | 
|  | 3 | +import respx | 
|  | 4 | + | 
|  | 5 | +from mpt_api_client.resources.catalog.pricing_policies import ( | 
|  | 6 | +    AsyncPricingPoliciesService, | 
|  | 7 | +    PricingPoliciesService, | 
|  | 8 | +) | 
|  | 9 | + | 
|  | 10 | + | 
|  | 11 | +@pytest.fixture | 
|  | 12 | +def pricing_policies_service(http_client): | 
|  | 13 | +    return PricingPoliciesService(http_client=http_client) | 
|  | 14 | + | 
|  | 15 | + | 
|  | 16 | +@pytest.fixture | 
|  | 17 | +def async_pricing_policies_service(async_http_client): | 
|  | 18 | +    return AsyncPricingPoliciesService(http_client=async_http_client) | 
|  | 19 | + | 
|  | 20 | + | 
|  | 21 | +def test_activate(pricing_policies_service): | 
|  | 22 | +    pricing_policy_expected = { | 
|  | 23 | +        "id": "PRP-0000-0001", | 
|  | 24 | +        "status": "Active", | 
|  | 25 | +        "name": "Active Pricing Policy", | 
|  | 26 | +    } | 
|  | 27 | +    with respx.mock: | 
|  | 28 | +        respx.post( | 
|  | 29 | +            "https://api.example.com/public/v1/catalog/pricing-policies/PRP-0000-0001/activate" | 
|  | 30 | +        ).mock( | 
|  | 31 | +            return_value=httpx.Response( | 
|  | 32 | +                status_code=httpx.codes.OK, | 
|  | 33 | +                json=pricing_policy_expected, | 
|  | 34 | +            ) | 
|  | 35 | +        ) | 
|  | 36 | + | 
|  | 37 | +        pricing_policy_activated = pricing_policies_service.activate( | 
|  | 38 | +            "PRP-0000-0001", {"name": "Active Pricing Policy"} | 
|  | 39 | +        ) | 
|  | 40 | + | 
|  | 41 | +        assert pricing_policy_activated.to_dict() == pricing_policy_expected | 
|  | 42 | + | 
|  | 43 | + | 
|  | 44 | +async def test_async_activate(async_pricing_policies_service): | 
|  | 45 | +    pricing_policy_expected = { | 
|  | 46 | +        "id": "PRP-0000-0001", | 
|  | 47 | +        "status": "Active", | 
|  | 48 | +        "name": "Active Pricing Policy", | 
|  | 49 | +    } | 
|  | 50 | +    with respx.mock: | 
|  | 51 | +        respx.post( | 
|  | 52 | +            "https://api.example.com/public/v1/catalog/pricing-policies/PRP-0000-0001/activate" | 
|  | 53 | +        ).mock( | 
|  | 54 | +            return_value=httpx.Response( | 
|  | 55 | +                status_code=httpx.codes.OK, | 
|  | 56 | +                json=pricing_policy_expected, | 
|  | 57 | +            ) | 
|  | 58 | +        ) | 
|  | 59 | + | 
|  | 60 | +        pricing_policy_activated = await async_pricing_policies_service.activate( | 
|  | 61 | +            "PRP-0000-0001", {"name": "Active Pricing Policy"} | 
|  | 62 | +        ) | 
|  | 63 | + | 
|  | 64 | +        assert pricing_policy_activated.to_dict() == pricing_policy_expected | 
|  | 65 | + | 
|  | 66 | + | 
|  | 67 | +def test_disable(pricing_policies_service): | 
|  | 68 | +    pricing_policy_expected = { | 
|  | 69 | +        "id": "PRP-0000-0001", | 
|  | 70 | +        "status": "Inactive", | 
|  | 71 | +        "name": "Inactive Pricing Policy", | 
|  | 72 | +    } | 
|  | 73 | +    with respx.mock: | 
|  | 74 | +        respx.post( | 
|  | 75 | +            "https://api.example.com/public/v1/catalog/pricing-policies/PRP-0000-0001/disable" | 
|  | 76 | +        ).mock( | 
|  | 77 | +            return_value=httpx.Response( | 
|  | 78 | +                status_code=httpx.codes.OK, | 
|  | 79 | +                json=pricing_policy_expected, | 
|  | 80 | +            ) | 
|  | 81 | +        ) | 
|  | 82 | + | 
|  | 83 | +        pricing_policy_disabled = pricing_policies_service.disable( | 
|  | 84 | +            "PRP-0000-0001", {"name": "Inactive Pricing Policy"} | 
|  | 85 | +        ) | 
|  | 86 | + | 
|  | 87 | +        assert pricing_policy_disabled.to_dict() == pricing_policy_expected | 
|  | 88 | + | 
|  | 89 | + | 
|  | 90 | +async def test_async_disable(async_pricing_policies_service): | 
|  | 91 | +    pricing_policy_expected = { | 
|  | 92 | +        "id": "PRP-0000-0001", | 
|  | 93 | +        "status": "Inactive", | 
|  | 94 | +        "name": "Inactive Pricing Policy", | 
|  | 95 | +    } | 
|  | 96 | +    with respx.mock: | 
|  | 97 | +        respx.post( | 
|  | 98 | +            "https://api.example.com/public/v1/catalog/pricing-policies/PRP-0000-0001/disable" | 
|  | 99 | +        ).mock( | 
|  | 100 | +            return_value=httpx.Response( | 
|  | 101 | +                status_code=httpx.codes.OK, | 
|  | 102 | +                json=pricing_policy_expected, | 
|  | 103 | +            ) | 
|  | 104 | +        ) | 
|  | 105 | + | 
|  | 106 | +        pricing_policy_disabled = await async_pricing_policies_service.disable( | 
|  | 107 | +            "PRP-0000-0001", {"name": "Inactive Pricing Policy"} | 
|  | 108 | +        ) | 
|  | 109 | + | 
|  | 110 | +        assert pricing_policy_disabled.to_dict() == pricing_policy_expected | 
0 commit comments