Skip to content

Commit 06cbca7

Browse files
committed
refactor: TT-185 add more scenarios to test_add_sql_in_condition_should_update_where_list
1 parent d538899 commit 06cbca7

File tree

1 file changed

+13
-37
lines changed

1 file changed

+13
-37
lines changed

tests/utils/query_builder_test.py

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ def test_add_select_conditions_should_update_select_list(
3636
(None, ["id"], []),
3737
("id", ["id"], ["c.id IN ('id')"]),
3838
("id", ["id1", "id2"], ["c.id IN ('id1', 'id2')"]),
39+
("owner_id", ["id1", "id2"], ["c.owner_id IN ('id1', 'id2')"]),
40+
("customer_id", ["id1", "id2"], ["c.customer_id IN ('id1', 'id2')"]),
3941
],
4042
)
4143
def test_add_sql_in_condition_should_update_where_list(
42-
attribute,
43-
ids_list,
44-
expected_where_condition_list,
44+
attribute, ids_list, expected_where_condition_list,
4545
):
4646
query_builder = CosmosDBQueryBuilder().add_sql_in_condition(
4747
attribute, ids_list
@@ -66,9 +66,7 @@ def test_add_sql_in_condition_should_update_where_list(
6666
],
6767
)
6868
def test_add_sql_where_equal_condition_should_update_where_params_list(
69-
data,
70-
expected_where_list,
71-
expected_params,
69+
data, expected_where_list, expected_params,
7270
):
7371
query_builder = CosmosDBQueryBuilder().add_sql_where_equal_condition(data)
7472

@@ -93,8 +91,7 @@ def test_add_sql_where_equal_condition_with_None_should_not_update_lists():
9391
[(True, ['NOT IS_DEFINED(c.deleted)']), (False, [])],
9492
)
9593
def test_add_sql_visibility_condition(
96-
visibility_bool,
97-
expected_where_list,
94+
visibility_bool, expected_where_list,
9895
):
9996
query_builder = CosmosDBQueryBuilder().add_sql_visibility_condition(
10097
visibility_bool
@@ -105,12 +102,7 @@ def test_add_sql_visibility_condition(
105102

106103

107104
@pytest.mark.parametrize(
108-
"limit_value,expected_limit",
109-
[
110-
(1, 1),
111-
(10, 10),
112-
(None, None),
113-
],
105+
"limit_value,expected_limit", [(1, 1), (10, 10), (None, None),],
114106
)
115107
def test_add_sql_limit_condition(limit_value, expected_limit):
116108
query_builder = CosmosDBQueryBuilder().add_sql_limit_condition(limit_value)
@@ -119,16 +111,10 @@ def test_add_sql_limit_condition(limit_value, expected_limit):
119111

120112

121113
@pytest.mark.parametrize(
122-
"offset_value,expected_offset",
123-
[
124-
(1, 1),
125-
(10, 10),
126-
(None, None),
127-
],
114+
"offset_value,expected_offset", [(1, 1), (10, 10), (None, None),],
128115
)
129116
def test_add_sql_offset_condition(
130-
offset_value,
131-
expected_offset,
117+
offset_value, expected_offset,
132118
):
133119
query_builder = CosmosDBQueryBuilder().add_sql_offset_condition(
134120
offset_value
@@ -139,15 +125,10 @@ def test_add_sql_offset_condition(
139125

140126
@pytest.mark.parametrize(
141127
"select_conditions,expected_condition",
142-
[
143-
([], "*"),
144-
(["c.id"], "c.id"),
145-
(["c.id", "c.name"], "c.id,c.name"),
146-
],
128+
[([], "*"), (["c.id"], "c.id"), (["c.id", "c.name"], "c.id,c.name"),],
147129
)
148130
def test__build_select_return_fields_in_select_list(
149-
select_conditions,
150-
expected_condition,
131+
select_conditions, expected_condition,
151132
):
152133
query_builder = CosmosDBQueryBuilder().add_select_conditions(
153134
select_conditions
@@ -165,8 +146,7 @@ def test__build_select_return_fields_in_select_list(
165146
],
166147
)
167148
def test__build_where_should_return_concatenate_conditions(
168-
where_dict,
169-
expected_condition,
149+
where_dict, expected_condition,
170150
):
171151
query_builder = CosmosDBQueryBuilder().add_sql_where_equal_condition(
172152
where_dict
@@ -182,9 +162,7 @@ def test__build_where_should_return_concatenate_conditions(
182162
[(1, "OFFSET @offset", [{'name': '@offset', 'value': 1}]), (None, "", [])],
183163
)
184164
def test__build_offset(
185-
offset,
186-
expected_condition,
187-
expected_params,
165+
offset, expected_condition, expected_params,
188166
):
189167
query_builder = CosmosDBQueryBuilder().add_sql_offset_condition(offset)
190168

@@ -199,9 +177,7 @@ def test__build_offset(
199177
[(1, "LIMIT @limit", [{'name': '@limit', 'value': 1}]), (None, "", [])],
200178
)
201179
def test__build_limit(
202-
limit,
203-
expected_condition,
204-
expected_params,
180+
limit, expected_condition, expected_params,
205181
):
206182
query_builder = CosmosDBQueryBuilder().add_sql_limit_condition(limit)
207183

0 commit comments

Comments
 (0)