python-amazon-sp-api 1.7.5__py3-none-any.whl → 2.0.10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_amazon_sp_api-1.7.5.data → python_amazon_sp_api-2.0.10.data}/scripts/make_endpoint +2 -2
- {python_amazon_sp_api-1.7.5.dist-info → python_amazon_sp_api-2.0.10.dist-info}/METADATA +58 -8
- python_amazon_sp_api-2.0.10.dist-info/RECORD +253 -0
- {python_amazon_sp_api-1.7.5.dist-info → python_amazon_sp_api-2.0.10.dist-info}/WHEEL +1 -1
- {python_amazon_sp_api-1.7.5.dist-info → python_amazon_sp_api-2.0.10.dist-info}/top_level.txt +0 -1
- sp_api/__version__.py +1 -1
- sp_api/api/__init__.py +48 -41
- sp_api/api/amazon_warehousing_and_distribu/amazon_warehousing_and_distribu.py +82 -76
- sp_api/api/aplus_content/aplus_content.py +76 -45
- sp_api/api/application_integrations/application_integrations.py +118 -0
- sp_api/api/application_management/application_management.py +6 -7
- sp_api/api/authorization/authorization.py +5 -5
- sp_api/api/catalog/catalog.py +9 -10
- sp_api/api/catalog_items/catalog_items.py +10 -13
- sp_api/api/customer_feedback/customer_feedback.py +110 -0
- sp_api/api/data_kiosk/data_kiosk.py +59 -39
- sp_api/api/easy_ship/easy_ship.py +190 -0
- sp_api/api/external_fulfillment/external_fulfillment.py +706 -0
- sp_api/api/fba_inbound_eligibility/fba_inbound_eligibility.py +23 -13
- sp_api/api/fba_small_and_light/fba_small_and_light.py +46 -20
- sp_api/api/feeds/feeds.py +60 -39
- sp_api/api/finances/finances.py +40 -9
- sp_api/api/fulfillment_inbound/fulfillment_inbound.py +844 -619
- sp_api/api/fulfillment_outbound/fulfillment_outbound.py +63 -57
- sp_api/api/inventories/inventories.py +13 -11
- sp_api/api/listings_items/listings_items.py +38 -25
- sp_api/api/listings_restrictions/listings_restrictions.py +6 -7
- sp_api/api/merchant_fulfillment/merchant_fulfillment.py +49 -36
- sp_api/api/messaging/messaging.py +129 -25
- sp_api/api/notifications/notifications.py +85 -45
- sp_api/api/orders/orders.py +123 -38
- sp_api/api/orders/orders_2026_01_01.py +54 -0
- sp_api/api/product_fees/product_fees.py +75 -67
- sp_api/api/product_type_definitions/product_type_definitions.py +9 -10
- sp_api/api/products/products.py +177 -53
- sp_api/api/products/products_definitions.py +11 -82
- sp_api/api/replenishment/replenishment.py +13 -11
- sp_api/api/reports/reports.py +113 -95
- sp_api/api/sales/sales.py +23 -13
- sp_api/api/sellers/sellers.py +3 -3
- sp_api/api/services/services.py +41 -30
- sp_api/api/shipping/shipping.py +39 -37
- sp_api/api/shipping/shippingV2.py +46 -30
- sp_api/api/solicitations/solicitations.py +20 -11
- sp_api/api/supply_sources/supply_sources.py +45 -37
- sp_api/api/tokens/tokens.py +4 -6
- sp_api/api/upload/upload.py +10 -8
- sp_api/api/vendor_direct_fulfillment_inventory/vendor_direct_fulfillment_inventory.py +10 -6
- sp_api/api/vendor_direct_fulfillment_orders/vendor_direct_fulfillment_orders.py +12 -14
- sp_api/api/vendor_direct_fulfillment_payments/vendor_direct_fulfillment_payments.py +4 -6
- sp_api/api/vendor_direct_fulfillment_shipping/vendor_direct_fulfillment_shipping.py +42 -37
- sp_api/api/vendor_direct_fulfillment_transactions/vendor_direct_fulfillment_transactions.py +8 -6
- sp_api/api/vendor_invoices/vendor_invoices.py +6 -4
- sp_api/api/vendor_orders/vendor_orders.py +16 -19
- sp_api/api/vendor_shipments/vendor_shipments.py +91 -262
- sp_api/api/vendor_transaction_status/vendor_transaction_status.py +6 -6
- sp_api/asyncio/api/__init__.py +167 -0
- sp_api/asyncio/api/amazon_warehousing_and_distribu/__init__.py +9 -0
- sp_api/asyncio/api/amazon_warehousing_and_distribu/amazon_warehousing_and_distribu.py +130 -0
- sp_api/asyncio/api/aplus_content/__init__.py +5 -0
- sp_api/asyncio/api/aplus_content/aplus_content.py +330 -0
- sp_api/asyncio/api/application_integrations/__init__.py +5 -0
- sp_api/asyncio/api/application_integrations/application_integrations.py +119 -0
- sp_api/asyncio/api/application_management/__init__.py +5 -0
- sp_api/asyncio/api/application_management/application_management.py +36 -0
- sp_api/asyncio/api/authorization/__init__.py +5 -0
- sp_api/asyncio/api/authorization/authorization.py +54 -0
- sp_api/asyncio/api/catalog/__init__.py +5 -0
- sp_api/asyncio/api/catalog/catalog.py +111 -0
- sp_api/asyncio/api/catalog_items/__init__.py +6 -0
- sp_api/asyncio/api/catalog_items/catalog_items.py +93 -0
- sp_api/asyncio/api/clients/__init__.py +1 -0
- sp_api/asyncio/api/customer_feedback/__init__.py +5 -0
- sp_api/asyncio/api/customer_feedback/customer_feedback.py +111 -0
- sp_api/asyncio/api/data_kiosk/__init__.py +5 -0
- sp_api/asyncio/api/data_kiosk/data_kiosk.py +236 -0
- sp_api/asyncio/api/easy_ship/__init__.py +5 -0
- sp_api/asyncio/api/easy_ship/easy_ship.py +191 -0
- sp_api/asyncio/api/external_fulfillment/__init__.py +5 -0
- sp_api/asyncio/api/external_fulfillment/external_fulfillment.py +706 -0
- sp_api/asyncio/api/fba_inbound_eligibility/__init__.py +5 -0
- sp_api/asyncio/api/fba_inbound_eligibility/fba_inbound_eligibility.py +96 -0
- sp_api/asyncio/api/fba_small_and_light/__init__.py +5 -0
- sp_api/asyncio/api/fba_small_and_light/fba_small_and_light.py +213 -0
- sp_api/asyncio/api/feeds/feeds.py +260 -0
- sp_api/asyncio/api/finances/finances.py +100 -0
- sp_api/asyncio/api/fulfillment_inbound/fulfillment_inbound.py +1798 -0
- sp_api/asyncio/api/fulfillment_outbound/fulfillment_outbound.py +736 -0
- sp_api/asyncio/api/inventories/inventories.py +74 -0
- sp_api/asyncio/api/listings_items/__init__.py +0 -0
- sp_api/asyncio/api/listings_items/listings_items.py +170 -0
- sp_api/asyncio/api/listings_restrictions/__init__.py +0 -0
- sp_api/asyncio/api/listings_restrictions/listings_restrictions.py +36 -0
- sp_api/asyncio/api/merchant_fulfillment/__init__.py +0 -0
- sp_api/asyncio/api/merchant_fulfillment/merchant_fulfillment.py +384 -0
- sp_api/asyncio/api/messaging/__init__.py +0 -0
- sp_api/asyncio/api/messaging/messaging.py +511 -0
- sp_api/asyncio/api/models/__init__.py +4 -0
- sp_api/asyncio/api/notifications/__init__.py +0 -0
- sp_api/asyncio/api/notifications/notifications.py +295 -0
- sp_api/asyncio/api/orders/__init__.py +0 -0
- sp_api/asyncio/api/orders/orders.py +412 -0
- sp_api/asyncio/api/orders/orders_2026_01_01.py +40 -0
- sp_api/asyncio/api/overrides/__init__.py +1 -0
- sp_api/asyncio/api/product_fees/__init__.py +0 -0
- sp_api/asyncio/api/product_fees/product_fees.py +194 -0
- sp_api/asyncio/api/product_type_definitions/__init__.py +0 -0
- sp_api/asyncio/api/product_type_definitions/product_type_definitions.py +75 -0
- sp_api/asyncio/api/products/__init__.py +0 -0
- sp_api/asyncio/api/products/products.py +405 -0
- sp_api/asyncio/api/products/products_definitions.py +11 -0
- sp_api/asyncio/api/replenishment/__init__.py +0 -0
- sp_api/asyncio/api/replenishment/replenishment.py +121 -0
- sp_api/asyncio/api/reports/__init__.py +0 -0
- sp_api/asyncio/api/reports/reports.py +439 -0
- sp_api/asyncio/api/sales/__init__.py +0 -0
- sp_api/asyncio/api/sales/sales.py +93 -0
- sp_api/asyncio/api/sellers/__init__.py +0 -0
- sp_api/asyncio/api/sellers/sellers.py +70 -0
- sp_api/asyncio/api/services/__init__.py +0 -0
- sp_api/asyncio/api/services/services.py +218 -0
- sp_api/asyncio/api/shipping/__init__.py +0 -0
- sp_api/asyncio/api/shipping/shipping.py +459 -0
- sp_api/asyncio/api/shipping/shippingV2.py +651 -0
- sp_api/asyncio/api/solicitations/__init__.py +0 -0
- sp_api/asyncio/api/solicitations/solicitations.py +78 -0
- sp_api/asyncio/api/supply_sources/__init__.py +0 -0
- sp_api/asyncio/api/supply_sources/supply_sources.py +138 -0
- sp_api/asyncio/api/tokens/__init__.py +0 -0
- sp_api/asyncio/api/tokens/tokens.py +65 -0
- sp_api/asyncio/api/upload/__init__.py +0 -0
- sp_api/asyncio/api/upload/upload.py +18 -0
- sp_api/asyncio/api/vendor_direct_fulfillment_inventory/__init__.py +0 -0
- sp_api/asyncio/api/vendor_direct_fulfillment_inventory/vendor_direct_fulfillment_inventory.py +64 -0
- sp_api/asyncio/api/vendor_direct_fulfillment_orders/__init__.py +0 -0
- sp_api/asyncio/api/vendor_direct_fulfillment_orders/vendor_direct_fulfillment_orders.py +196 -0
- sp_api/asyncio/api/vendor_direct_fulfillment_payments/__init__.py +0 -0
- sp_api/asyncio/api/vendor_direct_fulfillment_payments/vendor_direct_fulfillment_payments.py +254 -0
- sp_api/asyncio/api/vendor_direct_fulfillment_shipping/__init__.py +0 -0
- sp_api/asyncio/api/vendor_direct_fulfillment_shipping/vendor_direct_fulfillment_shipping.py +627 -0
- sp_api/asyncio/api/vendor_direct_fulfillment_transactions/__init__.py +0 -0
- sp_api/asyncio/api/vendor_direct_fulfillment_transactions/vendor_direct_fulfillment_transactions.py +43 -0
- sp_api/asyncio/api/vendor_invoices/__init__.py +0 -0
- sp_api/asyncio/api/vendor_invoices/vendor_invoices.py +295 -0
- sp_api/asyncio/api/vendor_orders/__init__.py +0 -0
- sp_api/asyncio/api/vendor_orders/vendor_orders.py +210 -0
- sp_api/asyncio/api/vendor_shipments/__init__.py +0 -0
- sp_api/asyncio/api/vendor_shipments/vendor_shipments.py +118 -0
- sp_api/asyncio/api/vendor_transaction_status/__init__.py +0 -0
- sp_api/asyncio/api/vendor_transaction_status/vendor_transaction_status.py +41 -0
- sp_api/asyncio/auth/__init__.py +12 -0
- sp_api/asyncio/auth/access_token_client.py +145 -0
- sp_api/asyncio/auth/exceptions.py +5 -0
- sp_api/asyncio/base/__init__.py +53 -0
- sp_api/asyncio/base/_transport_httpx.py +50 -0
- sp_api/asyncio/base/base_client.py +8 -0
- sp_api/asyncio/base/client.py +169 -0
- sp_api/asyncio/util/__init__.py +29 -0
- sp_api/asyncio/util/key_maker.py +5 -0
- sp_api/asyncio/util/load_all_pages.py +55 -0
- sp_api/asyncio/util/load_date_bound.py +53 -0
- sp_api/asyncio/util/retry.py +88 -0
- sp_api/auth/__init__.py +3 -3
- sp_api/auth/_core.py +39 -0
- sp_api/auth/access_token_client.py +20 -31
- sp_api/auth/access_token_response.py +4 -4
- sp_api/base/ApiResponse.py +5 -4
- sp_api/base/__init__.py +53 -42
- sp_api/base/_core.py +110 -0
- sp_api/base/_transport_httpx.py +39 -0
- sp_api/base/base_client.py +4 -4
- sp_api/base/client.py +131 -112
- sp_api/base/credential_provider.py +41 -34
- sp_api/base/exceptions.py +14 -3
- sp_api/base/feedTypes.py +44 -32
- sp_api/base/fulfillment_channel.py +2 -2
- sp_api/base/helpers.py +17 -16
- sp_api/base/identifiersType.py +8 -8
- sp_api/base/included_data.py +12 -12
- sp_api/base/marketplaces.py +5 -1
- sp_api/base/notifications.py +1 -1
- sp_api/base/processing_status.py +5 -5
- sp_api/base/reportTypes.py +198 -111
- sp_api/base/sales_enum.py +11 -13
- sp_api/util/__init__.py +42 -6
- sp_api/util/key_maker.py +4 -2
- sp_api/util/load_all_pages.py +16 -5
- sp_api/util/load_date_bound.py +28 -13
- sp_api/util/params.py +57 -0
- sp_api/util/product_fees.py +40 -0
- sp_api/util/products_definitions.py +169 -0
- sp_api/util/report_document.py +154 -0
- sp_api/util/retry.py +16 -15
- python_amazon_sp_api-1.7.5.dist-info/RECORD +0 -144
- tests/api/finances/test_finances.py +0 -19
- tests/api/notifications/test_notifications.py +0 -26
- tests/api/orders/test_orders.py +0 -122
- tests/api/product_fees/product_fees.py +0 -49
- tests/api/reports/test_reports.py +0 -127
- tests/client/test_auth.py +0 -59
- tests/client/test_base.py +0 -163
- tests/client/test_credential_provider.py +0 -45
- tests/client/test_helpers.py +0 -142
- {python_amazon_sp_api-1.7.5.dist-info → python_amazon_sp_api-2.0.10.dist-info/licenses}/LICENSE +0 -0
- {tests → sp_api/api/application_integrations}/__init__.py +0 -0
- {tests/api → sp_api/api/customer_feedback}/__init__.py +0 -0
- {tests/api/finances → sp_api/api/easy_ship}/__init__.py +0 -0
- {tests/api/notifications → sp_api/api/external_fulfillment}/__init__.py +0 -0
- {tests/api/orders → sp_api/asyncio}/__init__.py +0 -0
- {tests/api/product_fees → sp_api/asyncio/api/feeds}/__init__.py +0 -0
- {tests/api/reports → sp_api/asyncio/api/finances}/__init__.py +0 -0
- {tests/api/sellers → sp_api/asyncio/api/fulfillment_inbound}/__init__.py +0 -0
- {tests/client → sp_api/asyncio/api/fulfillment_outbound}/__init__.py +0 -0
- /tests/api/sellers/test_sellers.py → /sp_api/asyncio/api/inventories/__init__.py +0 -0
tests/client/test_base.py
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import pytest
|
|
3
|
-
|
|
4
|
-
from sp_api.api import FulfillmentInbound
|
|
5
|
-
from sp_api.base import AccessTokenClient
|
|
6
|
-
from sp_api.base import Marketplaces, MissingCredentials, Client, SellingApiForbiddenException
|
|
7
|
-
from sp_api.base.credential_provider import FromCodeCredentialProvider, FromEnvironmentVariablesCredentialProvider, \
|
|
8
|
-
FromSecretsCredentialProvider, FromConfigFileCredentialProvider, required_credentials
|
|
9
|
-
from sp_api.base.exceptions import MissingScopeException
|
|
10
|
-
|
|
11
|
-
refresh_token = '<refresh_token>'
|
|
12
|
-
lwa_app_id = '<lwa_app_id>'
|
|
13
|
-
lwa_client_secret = '<lwa_client_secret>'
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class Res:
|
|
17
|
-
status_code = 200
|
|
18
|
-
method = 'GET'
|
|
19
|
-
headers = {}
|
|
20
|
-
def json(self):
|
|
21
|
-
return {'foo': 'bar'}
|
|
22
|
-
|
|
23
|
-
def __getattr__(self, item):
|
|
24
|
-
return item
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def test_client_request():
|
|
28
|
-
try:
|
|
29
|
-
Client()._request('', data=dict())
|
|
30
|
-
except SellingApiForbiddenException as e:
|
|
31
|
-
assert isinstance(e, SellingApiForbiddenException)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def test_client_timeout():
|
|
35
|
-
client = Client(timeout=1)
|
|
36
|
-
assert client.timeout == 1
|
|
37
|
-
client = Client()
|
|
38
|
-
assert client.timeout is None
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
def test_api_response_has_next_token():
|
|
42
|
-
res = FulfillmentInbound().get_shipments(QueryType='SHIPMENT')
|
|
43
|
-
assert res.next_token is not None
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def test_marketplaces():
|
|
47
|
-
assert Marketplaces.DE.region == 'eu-west-1'
|
|
48
|
-
assert Marketplaces.US.marketplace_id == 'ATVPDKIKX0DER'
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def test_from_code_credential_provider():
|
|
52
|
-
p = FromCodeCredentialProvider(credentials=dict(
|
|
53
|
-
refresh_token=refresh_token,
|
|
54
|
-
lwa_app_id=lwa_app_id,
|
|
55
|
-
lwa_client_secret=lwa_client_secret,
|
|
56
|
-
))
|
|
57
|
-
assert p.credentials is not None
|
|
58
|
-
assert isinstance(p.credentials, dict)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
def test_from_code_credential_provider_no_refresh_token():
|
|
62
|
-
p = FromCodeCredentialProvider(credentials=dict(
|
|
63
|
-
lwa_app_id=lwa_app_id,
|
|
64
|
-
lwa_client_secret=lwa_client_secret,
|
|
65
|
-
))
|
|
66
|
-
assert p.credentials is not None
|
|
67
|
-
assert isinstance(p.credentials, dict)
|
|
68
|
-
assert p.credentials.get('refresh_token') is None
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
@pytest.mark.order(-2)
|
|
72
|
-
def test_env_vars_provider():
|
|
73
|
-
os.environ['SP_API_REFRESH_TOKEN'] = 'foo'
|
|
74
|
-
os.environ['LWA_APP_ID'] = 'foo'
|
|
75
|
-
os.environ['LWA_CLIENT_SECRET'] = 'foo'
|
|
76
|
-
|
|
77
|
-
p = FromEnvironmentVariablesCredentialProvider()()
|
|
78
|
-
assert 'refresh_token' in p
|
|
79
|
-
|
|
80
|
-
os.environ.pop('SP_API_REFRESH_TOKEN')
|
|
81
|
-
os.environ.pop('LWA_APP_ID')
|
|
82
|
-
os.environ.pop('LWA_CLIENT_SECRET')
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
@pytest.mark.order(-1)
|
|
86
|
-
def test_from_secrets():
|
|
87
|
-
os.environ['SP_API_AWS_SECRET_ID'] = 'testing/sp-api-foo'
|
|
88
|
-
try:
|
|
89
|
-
p = FromSecretsCredentialProvider()()
|
|
90
|
-
assert 'refresh_token' in p
|
|
91
|
-
assert p.get('refresh_token') == 'foo'
|
|
92
|
-
os.environ.pop('SP_API_AWS_SECRET_ID')
|
|
93
|
-
except MissingCredentials as e:
|
|
94
|
-
assert isinstance(e, MissingCredentials)
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
def test_from_config_file_provider():
|
|
98
|
-
try:
|
|
99
|
-
p = FromConfigFileCredentialProvider()()
|
|
100
|
-
assert p.get('refresh_token') is not None
|
|
101
|
-
except MissingCredentials as e:
|
|
102
|
-
assert isinstance(e, MissingCredentials)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def test_req():
|
|
106
|
-
assert len(required_credentials) == 2
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def test_client():
|
|
110
|
-
client = Client(marketplace=Marketplaces.UK)
|
|
111
|
-
assert client.marketplace_id == Marketplaces.UK.marketplace_id
|
|
112
|
-
assert client.credentials is not None
|
|
113
|
-
assert client.endpoint == Marketplaces.UK.endpoint
|
|
114
|
-
assert client.region == Marketplaces.UK.region
|
|
115
|
-
assert client.restricted_data_token is None
|
|
116
|
-
assert isinstance(client._auth, AccessTokenClient)
|
|
117
|
-
|
|
118
|
-
assert isinstance(client._get_cache_key(), str)
|
|
119
|
-
assert isinstance(client._get_cache_key('test'), str)
|
|
120
|
-
|
|
121
|
-
assert client.headers['host'] == client.endpoint[8:]
|
|
122
|
-
assert len(client.headers.keys()) == 5
|
|
123
|
-
|
|
124
|
-
assert client.auth is not None
|
|
125
|
-
try:
|
|
126
|
-
x = client.grantless_auth
|
|
127
|
-
except MissingScopeException as e:
|
|
128
|
-
assert isinstance(e, MissingScopeException)
|
|
129
|
-
|
|
130
|
-
try:
|
|
131
|
-
client._request('', data={})
|
|
132
|
-
except SellingApiForbiddenException as e:
|
|
133
|
-
assert isinstance(e, SellingApiForbiddenException)
|
|
134
|
-
try:
|
|
135
|
-
client._request('', params={})
|
|
136
|
-
except SellingApiForbiddenException as e:
|
|
137
|
-
assert isinstance(e, SellingApiForbiddenException)
|
|
138
|
-
|
|
139
|
-
check = client._check_response(Res())
|
|
140
|
-
assert check.payload['foo'] == 'bar'
|
|
141
|
-
|
|
142
|
-
r = Res()
|
|
143
|
-
r.method = 'POST'
|
|
144
|
-
check = client._check_response(r)
|
|
145
|
-
assert check.payload['foo'] == 'bar'
|
|
146
|
-
assert check('foo') == 'bar'
|
|
147
|
-
assert check.foo == 'bar'
|
|
148
|
-
assert check()['foo'] == 'bar'
|
|
149
|
-
|
|
150
|
-
r.method = 'DELETE'
|
|
151
|
-
check = client._check_response(r)
|
|
152
|
-
assert check.payload['foo'] == 'bar'
|
|
153
|
-
assert check('foo') == 'bar'
|
|
154
|
-
assert check.foo == 'bar'
|
|
155
|
-
assert check()['foo'] == 'bar'
|
|
156
|
-
|
|
157
|
-
client.grantless_scope = 'sellingpartnerapi::notifications'
|
|
158
|
-
assert client.grantless_auth is not None
|
|
159
|
-
|
|
160
|
-
try:
|
|
161
|
-
client._request_grantless_operation('')
|
|
162
|
-
except SellingApiForbiddenException as e:
|
|
163
|
-
assert isinstance(e, SellingApiForbiddenException)
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from unittest import mock
|
|
3
|
-
|
|
4
|
-
from sp_api.base.credential_provider import FromCachedSecretsCredentialProvider
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
REFRESH_TOKEN = '<refresh_token>'
|
|
8
|
-
LWA_APP_ID = '<lwa_app_id>'
|
|
9
|
-
LWA_CLIENT_SECRET = '<lwa_client_secret>'
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def test_from_cached_secrets_cp_without_secret_id_set():
|
|
13
|
-
with mock.patch.dict(os.environ, {"SP_API_AWS_SECRET_ID": ""}):
|
|
14
|
-
cp = FromCachedSecretsCredentialProvider()
|
|
15
|
-
cp.load_credentials()
|
|
16
|
-
|
|
17
|
-
assert cp.credentials is None
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def test_from_cached_secrets_cp_without_cache_available():
|
|
21
|
-
with mock.patch.dict(os.environ, {"SP_API_AWS_SECRET_ID": "test"}), \
|
|
22
|
-
mock.patch.object(FromCachedSecretsCredentialProvider, "_get_secret_cache", return_value=None):
|
|
23
|
-
cp = FromCachedSecretsCredentialProvider()
|
|
24
|
-
cp.load_credentials()
|
|
25
|
-
|
|
26
|
-
assert cp.credentials is None
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def test_from_cached_secrets_cp_with_cache_available():
|
|
30
|
-
secret_content = {
|
|
31
|
-
"SP_API_REFRESH_TOKEN": REFRESH_TOKEN,
|
|
32
|
-
"LWA_APP_ID": LWA_APP_ID,
|
|
33
|
-
"LWA_CLIENT_SECRET": LWA_CLIENT_SECRET,
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
with mock.patch.dict(os.environ, {"SP_API_AWS_SECRET_ID": "test"}), \
|
|
37
|
-
mock.patch.object(FromCachedSecretsCredentialProvider, "get_secret_content", return_value=secret_content):
|
|
38
|
-
cp = FromCachedSecretsCredentialProvider()
|
|
39
|
-
cp.load_credentials()
|
|
40
|
-
|
|
41
|
-
assert cp.credentials == {
|
|
42
|
-
"refresh_token": REFRESH_TOKEN,
|
|
43
|
-
"lwa_app_id": LWA_APP_ID,
|
|
44
|
-
"lwa_client_secret": LWA_CLIENT_SECRET,
|
|
45
|
-
}
|
tests/client/test_helpers.py
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import enum
|
|
2
|
-
import os
|
|
3
|
-
from datetime import datetime, timedelta
|
|
4
|
-
from io import BytesIO
|
|
5
|
-
|
|
6
|
-
from sp_api.api import FulfillmentInbound, Orders
|
|
7
|
-
from sp_api.base import fill_query_params, sp_endpoint, create_md5, nest_dict, deprecated
|
|
8
|
-
from sp_api.util import KeyMaker, load_all_pages, throttle_retry, load_date_bound
|
|
9
|
-
from sp_api.util.load_all_pages import make_sleep_time
|
|
10
|
-
|
|
11
|
-
key_mapping = {
|
|
12
|
-
'sku': ['seller_sku', 'sellerSku'],
|
|
13
|
-
'title': ['product_name']
|
|
14
|
-
}
|
|
15
|
-
test_obj = {
|
|
16
|
-
'goo': {'x': {}},
|
|
17
|
-
'seller_sku': 1,
|
|
18
|
-
'product_name': {
|
|
19
|
-
'sellerSku': [
|
|
20
|
-
'seller_sku',
|
|
21
|
-
3,
|
|
22
|
-
{
|
|
23
|
-
'sellerSku': 22,
|
|
24
|
-
'product_name': {
|
|
25
|
-
'title': 'Foo',
|
|
26
|
-
'x': 'bar'
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
]
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def test_key_maker_from_dict():
|
|
35
|
-
r = KeyMaker(key_mapping, deep=True).convert_keys(test_obj)
|
|
36
|
-
assert isinstance(r, dict)
|
|
37
|
-
assert r.get('sku') == 1
|
|
38
|
-
assert r.get('seller_sku') is None
|
|
39
|
-
assert isinstance(r.get('title'), dict)
|
|
40
|
-
assert isinstance(r.get('title').get('sku'), list)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def test_key_maker_from_list():
|
|
44
|
-
r = KeyMaker(key_mapping, deep=True).convert_keys([test_obj])
|
|
45
|
-
assert isinstance(r, list)
|
|
46
|
-
assert len(r) == 1
|
|
47
|
-
|
|
48
|
-
assert r[0].get('sku') == 1
|
|
49
|
-
assert r[0].get('seller_sku') is None
|
|
50
|
-
assert isinstance(r[0].get('title'), dict)
|
|
51
|
-
assert isinstance(r[0].get('title').get('sku'), list)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def test_key_maker_from_dict_not_deep():
|
|
55
|
-
r = KeyMaker(key_mapping, deep=False).convert_keys(test_obj)
|
|
56
|
-
assert r.get('sku') == 1
|
|
57
|
-
assert r.get('seller_sku') is None
|
|
58
|
-
assert isinstance(r.get('title'), dict)
|
|
59
|
-
assert isinstance(r.get('title').get('sellerSku'), list)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
def test_load_all_pages():
|
|
63
|
-
@throttle_retry()
|
|
64
|
-
@load_all_pages(extras=dict(QueryType='NEXT_TOKEN'))
|
|
65
|
-
def load_shipments(**kwargs):
|
|
66
|
-
return FulfillmentInbound().get_shipments(**kwargs)
|
|
67
|
-
|
|
68
|
-
for x in load_shipments(QueryType='SHIPMENT'):
|
|
69
|
-
assert x.payload is not None
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
def test_load_all_pages_orders():
|
|
73
|
-
@throttle_retry()
|
|
74
|
-
@load_all_pages()
|
|
75
|
-
def load_all_orders(**kwargs):
|
|
76
|
-
return Orders().get_orders(**kwargs)
|
|
77
|
-
|
|
78
|
-
for x in load_all_orders(CreatedAfter='TEST_CASE_200', MarketplaceIds=["ATVPDKIKX0DER"]):
|
|
79
|
-
assert x.payload is not None
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
def test_make_sleep_time():
|
|
83
|
-
x = make_sleep_time(2, False, 2)
|
|
84
|
-
assert x == 2
|
|
85
|
-
|
|
86
|
-
y = make_sleep_time(2, True, 2)
|
|
87
|
-
assert y == 0.5
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
def test_load_all_pages1():
|
|
91
|
-
x = load_all_pages()
|
|
92
|
-
assert x is not None
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
def test_fill_query_params():
|
|
96
|
-
assert fill_query_params('{}/{}', 'foo', 'bar') == 'foo/bar'
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
def test_sp_endpoint_():
|
|
100
|
-
assert sp_endpoint('foo') is not None
|
|
101
|
-
|
|
102
|
-
@sp_endpoint('/api/call', method='POST')
|
|
103
|
-
def my_endpoint(**kwargs):
|
|
104
|
-
assert kwargs['path'] == '/api/call'
|
|
105
|
-
assert kwargs['method'] == 'POST'
|
|
106
|
-
my_endpoint()
|
|
107
|
-
assert my_endpoint.__name__ == 'my_endpoint'
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
def test_create_md5():
|
|
111
|
-
b = BytesIO()
|
|
112
|
-
b.write(b'foo')
|
|
113
|
-
b.seek(0)
|
|
114
|
-
m = create_md5(b)
|
|
115
|
-
assert m == 'rL0Y20zC+Fzt72VPzMSk2A=='
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
def test_nest_dict():
|
|
119
|
-
x = nest_dict({
|
|
120
|
-
"AmazonOrderId":1,
|
|
121
|
-
"ShipFromAddress.Name" : "Seller",
|
|
122
|
-
"ShipFromAddress.AddressLine1": "Street",
|
|
123
|
-
})
|
|
124
|
-
assert x['ShipFromAddress']['AddressLine1'] == 'Street'
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
def test_deprecated():
|
|
128
|
-
assert deprecated(lambda x: x + 1)(1) == 2
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
@load_date_bound()
|
|
132
|
-
def dummy(**kwargs):
|
|
133
|
-
return lambda: kwargs
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
def test_load_date_bound():
|
|
137
|
-
start = datetime.now() - timedelta(days=70)
|
|
138
|
-
end = datetime.now()
|
|
139
|
-
x = list(dummy(dataStartTime=start, dataEndTime=end))
|
|
140
|
-
assert len(x) == 3
|
|
141
|
-
assert x[1]()['dataStartTime'] == start + timedelta(days=30)
|
|
142
|
-
assert x[1]()['dataEndTime'] == start + timedelta(days=60)
|
{python_amazon_sp_api-1.7.5.dist-info → python_amazon_sp_api-2.0.10.dist-info/licenses}/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|