1- import pytest
1+ import os
2+
23import requests
34
45from commercetools import Client
5- from commercetools .types import LocalizedString , ProductDraft
6+ from commercetools .types import LocalizedString , ProductDraft , ChannelDraft , ChannelRoleEnum , ChannelResourceIdentifier , \
7+ StoreDraft
68
79
810def test_http_server (commercetools_client , commercetools_http_server ):
9- import os
10-
1111 os .environ ["OAUTHLIB_INSECURE_TRANSPORT" ] = "1"
1212
1313 client = Client (
@@ -30,3 +30,32 @@ def test_http_server(commercetools_client, commercetools_http_server):
3030 assert response .status_code == 200 , response .text
3131 data = response .json ()
3232 assert data ["masterData" ]["staged" ]["name" ]["nl" ] == "Testje"
33+
34+
35+ def test_http_server_expanding (commercetools_client , commercetools_http_server ):
36+ os .environ ["OAUTHLIB_INSECURE_TRANSPORT" ] = "1"
37+
38+ client = Client (
39+ project_key = "unittest" ,
40+ client_id = "client-id" ,
41+ client_secret = "client-secret" ,
42+ scope = [],
43+ url = commercetools_http_server .api_url ,
44+ token_url = f"{ commercetools_http_server .api_url } /oauth/token" ,
45+ )
46+
47+ client .channels .create (
48+ ChannelDraft (
49+ key = "FOO" , roles = [ChannelRoleEnum .PRODUCT_DISTRIBUTION ]
50+ )
51+ )
52+
53+ store = client .stores .create (StoreDraft (key = "FOO" , distribution_channels = [ChannelResourceIdentifier (key = "FOO" )]))
54+
55+ url = commercetools_http_server .api_url + f"/unittest/stores/{ store .id } "
56+ response = requests .get (url , params = {"expand" : "distributionChannels[*]" }, headers = {"Authorization" : "Bearer token" })
57+
58+ assert response .status_code == 200 , response .text
59+ data = response .json ()
60+
61+ assert data ["distributionChannels" ][0 ]["obj" ]["key" ] == "FOO"
0 commit comments