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 (
7+ ChannelDraft ,
8+ ChannelResourceIdentifier ,
9+ ChannelRoleEnum ,
10+ LocalizedString ,
11+ ProductDraft ,
12+ StoreDraft ,
13+ )
614
715
816def test_http_server (commercetools_client , commercetools_http_server ):
9- import os
10-
1117 os .environ ["OAUTHLIB_INSECURE_TRANSPORT" ] = "1"
1218
1319 client = Client (
@@ -30,3 +36,38 @@ def test_http_server(commercetools_client, commercetools_http_server):
3036 assert response .status_code == 200 , response .text
3137 data = response .json ()
3238 assert data ["masterData" ]["staged" ]["name" ]["nl" ] == "Testje"
39+
40+
41+ def test_http_server_expanding (commercetools_client , commercetools_http_server ):
42+ os .environ ["OAUTHLIB_INSECURE_TRANSPORT" ] = "1"
43+
44+ client = Client (
45+ project_key = "unittest" ,
46+ client_id = "client-id" ,
47+ client_secret = "client-secret" ,
48+ scope = [],
49+ url = commercetools_http_server .api_url ,
50+ token_url = f"{ commercetools_http_server .api_url } /oauth/token" ,
51+ )
52+
53+ client .channels .create (
54+ ChannelDraft (key = "FOO" , roles = [ChannelRoleEnum .PRODUCT_DISTRIBUTION ])
55+ )
56+
57+ store = client .stores .create (
58+ StoreDraft (
59+ key = "FOO" , distribution_channels = [ChannelResourceIdentifier (key = "FOO" )]
60+ )
61+ )
62+
63+ url = commercetools_http_server .api_url + f"/unittest/stores/{ store .id } "
64+ response = requests .get (
65+ url ,
66+ params = {"expand" : "distributionChannels[*]" },
67+ headers = {"Authorization" : "Bearer token" },
68+ )
69+
70+ assert response .status_code == 200 , response .text
71+ data = response .json ()
72+
73+ assert data ["distributionChannels" ][0 ]["obj" ]["key" ] == "FOO"
0 commit comments