-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_mpt_client.py
More file actions
112 lines (93 loc) · 3.02 KB
/
Copy pathtest_mpt_client.py
File metadata and controls
112 lines (93 loc) · 3.02 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import pytest
from mpt_api_client.auth import BearerTokenAuthentication
from mpt_api_client.http import AsyncHTTPClient, HTTPClient
from mpt_api_client.mpt_client import AsyncMPTClient, MPTClient
from mpt_api_client.resources import (
Accounts,
AsyncAccounts,
AsyncAudit,
AsyncBilling,
AsyncCatalog,
AsyncCommerce,
AsyncExchange,
AsyncHelpdesk,
AsyncIntegration,
AsyncNotifications,
AsyncProgram,
AsyncSpotlight,
Audit,
Billing,
Catalog,
Commerce,
Exchange,
Helpdesk,
Integration,
Notifications,
Program,
Spotlight,
)
from tests.unit.conftest import API_TOKEN, API_URL
def get_mpt_client():
return MPTClient.from_config(
base_url=API_URL, authentication=BearerTokenAuthentication(API_TOKEN)
)
@pytest.mark.parametrize(
("resource_name", "expected_type"),
[
("commerce", Commerce),
("catalog", Catalog),
("audit", Audit),
("billing", Billing),
("accounts", Accounts),
("notifications", Notifications),
("helpdesk", Helpdesk),
("exchange", Exchange),
("integration", Integration),
("program", Program),
("spotlight", Spotlight),
],
)
def test_mpt_client(resource_name: str, expected_type: type) -> None:
mpt = MPTClient.from_config(
base_url=API_URL, authentication=BearerTokenAuthentication(API_TOKEN)
)
result = getattr(mpt, resource_name)
assert isinstance(mpt, MPTClient)
assert isinstance(result, expected_type)
def test_mpt_client_from_config(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("MPT_API_BASE_URL", API_URL)
result = MPTClient.from_config(
base_url=API_URL, authentication=BearerTokenAuthentication(API_TOKEN)
)
assert isinstance(result, MPTClient)
assert isinstance(result.http_client, HTTPClient)
@pytest.mark.parametrize(
("resource_name", "expected_type"),
[
("commerce", AsyncCommerce),
("catalog", AsyncCatalog),
("audit", AsyncAudit),
("billing", AsyncBilling),
("accounts", AsyncAccounts),
("notifications", AsyncNotifications),
("helpdesk", AsyncHelpdesk),
("exchange", AsyncExchange),
("integration", AsyncIntegration),
("program", AsyncProgram),
("spotlight", AsyncSpotlight),
],
)
def test_async_mpt_client(resource_name: str, expected_type: type) -> None:
mpt = AsyncMPTClient.from_config(
base_url=API_URL, authentication=BearerTokenAuthentication(API_TOKEN)
)
result = getattr(mpt, resource_name)
assert isinstance(mpt, AsyncMPTClient)
assert isinstance(result, expected_type)
def test_async_mpt_client_from_config(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("MPT_API_BASE_URL", API_URL)
result = AsyncMPTClient.from_config(
base_url=API_URL, authentication=BearerTokenAuthentication(API_TOKEN)
)
assert isinstance(result, AsyncMPTClient)
assert isinstance(result.http_client, AsyncHTTPClient)