labd / commercetools-python-sdk

Commercetools Python SDK
https://commercetools-python-sdk.readthedocs.io/en/latest/
MIT License
17 stars 16 forks source link

New commercetools.platform.Client not compatible with pytest mocker #132

Closed robmoorman closed 2 years ago

robmoorman commented 3 years ago

When using the (as docs described) Client imported from from commercetools.platform import Client the pytest fixture commercetools_api doesn't work.

It looks like no http requests are mocked and actual requests are triggered (instead of using the mocker), causing the invalid token exception.

Using the "old" from commercetools.import Client fixes the problem (although it uses a slighly different API).

Tested with commercetools version 14.

mvantellingen commented 3 years ago

I believe that pytest fixture is for the old API. The new fixture is ct_platform_client: PlatformClient. See https://github.com/labd/commercetools-python-sdk/blob/main/tests/platform/test_expand.py#L7

robmoorman commented 3 years ago

I believe that pytest fixture is for the old API. The new fixture is ct_platform_client: PlatformClient. See https://github.com/labd/commercetools-python-sdk/blob/main/tests/platform/test_expand.py#L7

Ok let me confirm this