|
| 1 | +import pytest |
| 2 | + |
| 3 | +from mpt_api_client.resources.catalog.price_list_items import ( |
| 4 | + AsyncPriceListItemsService, |
| 5 | + PriceListItemsService, |
| 6 | +) |
| 7 | +from mpt_api_client.resources.catalog.price_lists import ( |
| 8 | + AsyncPriceListsService, |
| 9 | + PriceListsService, |
| 10 | +) |
| 11 | + |
| 12 | + |
| 13 | +@pytest.fixture |
| 14 | +def price_lists_service(http_client): |
| 15 | + return PriceListsService(http_client=http_client) |
| 16 | + |
| 17 | + |
| 18 | +@pytest.fixture |
| 19 | +def async_price_lists_service(http_client): |
| 20 | + return AsyncPriceListsService(http_client=http_client) |
| 21 | + |
| 22 | + |
| 23 | +@pytest.mark.parametrize("method", ["get", "create", "update", "delete"]) |
| 24 | +def test_mixins_present(price_lists_service, method): |
| 25 | + assert hasattr(price_lists_service, method) |
| 26 | + |
| 27 | + |
| 28 | +@pytest.mark.parametrize("method", ["get", "create", "update", "delete"]) |
| 29 | +def test_async_mixins_present(async_price_lists_service, method): |
| 30 | + assert hasattr(async_price_lists_service, method) |
| 31 | + |
| 32 | + |
| 33 | +@pytest.mark.parametrize( |
| 34 | + ("service_method", "expected_model_class"), |
| 35 | + [ |
| 36 | + ("items", PriceListItemsService), |
| 37 | + ], |
| 38 | +) |
| 39 | +def test_property_services(price_lists_service, service_method, expected_model_class): |
| 40 | + property_service = getattr(price_lists_service, service_method)("ITM-0000-0001") |
| 41 | + |
| 42 | + assert isinstance(property_service, expected_model_class) |
| 43 | + assert property_service.endpoint_params == {"price_list_id": "ITM-0000-0001"} |
| 44 | + |
| 45 | + |
| 46 | +@pytest.mark.parametrize( |
| 47 | + ("service_method", "expected_model_class"), |
| 48 | + [ |
| 49 | + ("items", AsyncPriceListItemsService), |
| 50 | + ], |
| 51 | +) |
| 52 | +def test_async_property_services(async_price_lists_service, service_method, expected_model_class): |
| 53 | + property_service = getattr(async_price_lists_service, service_method)("ITM-0000-0001") |
| 54 | + |
| 55 | + assert isinstance(property_service, expected_model_class) |
| 56 | + assert property_service.endpoint_params == {"price_list_id": "ITM-0000-0001"} |
0 commit comments