-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_rql_parse_kwargs.py
More file actions
45 lines (24 loc) · 1.2 KB
/
test_rql_parse_kwargs.py
File metadata and controls
45 lines (24 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import pytest
from mpt_api_client.rql.query_builder import parse_kwargs
@pytest.fixture
def mock_product_ids_for_expression():
return ["PRD-1", "PRD-2"]
@pytest.fixture
def mock_product_id_for_expression():
return "PRD-1"
def test_improper_op(mock_product_id_for_expression):
products_expr = {"product__id__inn": mock_product_id_for_expression}
result = parse_kwargs(products_expr)
assert str(result) == f"[\"eq(product.id.inn,'{mock_product_id_for_expression}')\"]"
def test_parse_eq(mock_product_id_for_expression):
products_expr = {"product__id__eq": mock_product_id_for_expression}
result = parse_kwargs(products_expr)
assert str(result) == f"[\"eq(product.id,'{mock_product_id_for_expression}')\"]"
def test_parse_like(mock_product_id_for_expression):
products_expr = {"product__id__like": mock_product_id_for_expression}
result = parse_kwargs(products_expr)
assert str(result) == f"['like(product.id,{mock_product_id_for_expression})']"
def test_parse_null_op(mock_product_id_for_expression):
products_expr = {"product__id__null": mock_product_id_for_expression}
result = parse_kwargs(products_expr)
assert str(result) == "['ne(product.id,null())']"