-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_catalog.py
More file actions
76 lines (59 loc) · 2.54 KB
/
test_catalog.py
File metadata and controls
76 lines (59 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import pytest
from mpt_api_client.resources.catalog.authorizations import (
AsyncAuthorizationsService,
AuthorizationsService,
)
from mpt_api_client.resources.catalog.catalog import AsyncCatalog, Catalog
from mpt_api_client.resources.catalog.items import AsyncItemsService, ItemsService
from mpt_api_client.resources.catalog.listings import AsyncListingsService, ListingsService
from mpt_api_client.resources.catalog.price_lists import (
AsyncPriceListsService,
PriceListsService,
)
from mpt_api_client.resources.catalog.products import AsyncProductsService, ProductsService
@pytest.fixture
def catalog(http_client):
return Catalog(http_client=http_client)
@pytest.fixture
def async_catalog(async_http_client):
return AsyncCatalog(http_client=async_http_client)
@pytest.mark.parametrize(
("property_name", "expected_service_class"),
[
("authorizations", AuthorizationsService),
("listings", ListingsService),
("price_lists", PriceListsService),
("products", ProductsService),
("items", ItemsService),
],
)
def test_catalog_properties(catalog, property_name, expected_service_class):
"""Test that Catalog properties return correct instances."""
service = getattr(catalog, property_name)
assert isinstance(service, expected_service_class)
assert service.http_client is catalog.http_client
@pytest.mark.parametrize(
("property_name", "expected_service_class"),
[
("authorizations", AsyncAuthorizationsService),
("listings", AsyncListingsService),
("price_lists", AsyncPriceListsService),
("products", AsyncProductsService),
("items", AsyncItemsService),
],
)
def test_async_catalog_properties(async_catalog, property_name, expected_service_class):
"""Test that AsyncCatalog properties return correct instances."""
service = getattr(async_catalog, property_name)
assert isinstance(service, expected_service_class)
assert service.http_client is async_catalog.http_client
def test_catalog_initialization(http_client):
"""Test that Catalog can be properly initialized with http_client."""
catalog = Catalog(http_client=http_client)
assert catalog.http_client is http_client
assert isinstance(catalog, Catalog)
def test_async_catalog_initialization(async_http_client):
"""Test that AsyncCatalog can be properly initialized with http_client."""
async_catalog = AsyncCatalog(http_client=async_http_client)
assert async_catalog.http_client is async_http_client
assert isinstance(async_catalog, AsyncCatalog)