|
1 | 1 | import commercetools |
2 | 2 | from commercetools.platform import models |
| 3 | +from commercetools.platform import Client as PlatformClient |
3 | 4 | from tests.platform.test_service_order import get_test_order |
4 | 5 |
|
5 | 6 |
|
6 | | -def test_unknown_expand_terms(old_client: commercetools.Client): |
7 | | - cart = old_client.carts.create(models.CartDraft(currency="EUR")) |
8 | | - |
9 | | - order = old_client.orders.create( |
10 | | - models.OrderFromCartDraft( |
11 | | - id=cart.id, version=1, cart=cart, order_number="test-order" |
12 | | - ), |
13 | | - expand="nonExisting", |
| 7 | +def test_unknown_expand_terms(ct_platform_client: PlatformClient): |
| 8 | + cart = ( |
| 9 | + ct_platform_client.with_project_key("unittest") |
| 10 | + .carts() |
| 11 | + .post(models.CartDraft(currency="EUR")) |
| 12 | + ) |
| 13 | + assert cart |
| 14 | + |
| 15 | + order = ( |
| 16 | + ct_platform_client.with_project_key("unittest") |
| 17 | + .orders() |
| 18 | + .post( |
| 19 | + models.OrderFromCartDraft( |
| 20 | + id=cart.id, |
| 21 | + version=1, |
| 22 | + cart=models.CartResourceIdentifier(id=cart.id), |
| 23 | + order_number="test-order", |
| 24 | + ), |
| 25 | + expand=["nonExisting"], |
| 26 | + ) |
14 | 27 | ) |
15 | 28 |
|
16 | 29 | assert order.id |
17 | 30 |
|
18 | 31 |
|
19 | | -def test_optional_expanded_terms(old_client, commercetools_api): |
| 32 | +def test_optional_expanded_terms(ct_platform_client: PlatformClient, commercetools_api): |
20 | 33 | order = get_test_order() |
21 | 34 | commercetools_api.orders.add_existing(order) |
22 | 35 |
|
23 | | - expanded_order = old_client.orders.get_by_id( |
24 | | - order.id, expand="discountCodes[*].discountCode" |
| 36 | + expanded_order = ( |
| 37 | + ct_platform_client.with_project_key("unittest") |
| 38 | + .orders() |
| 39 | + .with_id(order.id) |
| 40 | + .get(expand=["discountCodes[*].discountCode"]) |
25 | 41 | ) |
26 | 42 |
|
27 | 43 | assert expanded_order.id |
28 | 44 | assert expanded_order.discount_codes is None |
29 | 45 |
|
30 | 46 |
|
31 | | -def test_unknown_reference_expand_terms(old_client, commercetools_api): |
| 47 | +def test_unknown_reference_expand_terms( |
| 48 | + ct_platform_client: PlatformClient, commercetools_api |
| 49 | +): |
32 | 50 | order = get_test_order() |
33 | 51 | commercetools_api.orders.add_existing(order) |
34 | 52 |
|
35 | | - expanded_order = old_client.orders.get_by_id( |
36 | | - order.id, expand="shippingInfo.shippingMethod" |
| 53 | + expanded_order = ( |
| 54 | + ct_platform_client.with_project_key("unittest") |
| 55 | + .orders() |
| 56 | + .with_id(order.id) |
| 57 | + .get(expand=["shippingInfo.shippingMethod"]) |
37 | 58 | ) |
38 | 59 |
|
39 | 60 | assert expanded_order.id |
|
0 commit comments