Skip to content

Commit e4fd25e

Browse files
feat: support in syntax for single values (#109)
Commercetools API supports this as well, so we should emulate it. Co-authored-by: David Weterings <d.weterings@labdigital.nl>
1 parent 1bf13b4 commit e4fd25e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/commercetools/testing/predicates.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,10 @@ def filter_field(
514514
if operator_value == "in":
515515
return op(value, obj)
516516

517+
# allow comparing single values with 'in' syntax
518+
if operator_value == "in" and not isinstance(value, list):
519+
return op([value], obj)
520+
517521
return op(obj, value)
518522

519523
def case_insensitive_get(sef, dict, key, default=None):

tests/test_service_order.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,12 @@ def get_test_order():
268268
refused_gifts=[],
269269
)
270270
return order
271+
272+
273+
def test_where_query_state(commercetools_api, client):
274+
order = get_test_order()
275+
commercetools_api.orders.add_existing(order)
276+
277+
result = client.orders.query(where='orderState in ("Open")')
278+
279+
assert result.results[0].id == order.id

0 commit comments

Comments
 (0)