Skip to content

Commit be72ff8

Browse files
committed
refactor: TT-185 rename get_string_without_empty_spaces to remove_white_spaces
1 parent f1fc8a6 commit be72ff8

File tree

4 files changed

+24
-19
lines changed

4 files changed

+24
-19
lines changed

tests/time_tracker_api/time_entries/time_entries_query_builder_test.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from time_tracker_api.time_entries.time_entries_query_builder import (
55
TimeEntryQueryBuilder,
66
)
7-
from utils.repository import get_string_without_empty_spaces
7+
from utils.repository import remove_white_spaces
88

99

1010
def test_TimeEntryQueryBuilder_is_subclass_CosmosDBQueryBuilder():
@@ -73,9 +73,7 @@ def test_build_with_add_sql_date_range_condition():
7373
"""
7474
query = time_entry_query_builder.get_query()
7575

76-
assert get_string_without_empty_spaces(
77-
query
78-
) == get_string_without_empty_spaces(expected_query)
76+
assert remove_white_spaces(query) == remove_white_spaces(expected_query)
7977

8078
assert len(time_entry_query_builder.where_conditions) == 1
8179
assert len(time_entry_query_builder.get_parameters()) == 2

tests/utils/query_builder_test.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from unittest.mock import patch
22
from utils.query_builder import CosmosDBQueryBuilder
3-
from utils.repository import get_string_without_empty_spaces
3+
from utils.repository import remove_white_spaces
44
import pytest
55

66

@@ -234,9 +234,7 @@ def test_build_with_all_calls_return_query_with_all_conditions():
234234
LIMIT @limit
235235
"""
236236

237-
assert get_string_without_empty_spaces(
238-
query
239-
) == get_string_without_empty_spaces(expected_query)
237+
assert remove_white_spaces(query) == remove_white_spaces(expected_query)
240238

241239
assert len(query_builder.get_parameters()) > 0
242240
assert len(query_builder.where_conditions) > 0
@@ -258,8 +256,8 @@ def test_build_with_empty_and_None_attributes_return_query_select_all():
258256
query = query_builder.get_query()
259257

260258
expected_query = """SELECT * FROM c"""
261-
query = get_string_without_empty_spaces(query)
262-
expected_query = get_string_without_empty_spaces(expected_query)
259+
query = remove_white_spaces(query)
260+
expected_query = remove_white_spaces(expected_query)
263261

264262
assert query == expected_query
265263
assert len(query_builder.get_parameters()) == 0

tests/utils/repository_test.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
from unittest.mock import patch
2-
from utils.repository import convert_list_to_tuple_string, create_sql_in_condition
3-
from utils.repository import get_string_without_empty_spaces
2+
from utils.repository import (
3+
convert_list_to_tuple_string,
4+
create_sql_in_condition,
5+
remove_white_spaces,
6+
)
47
import pytest
58

69

@@ -42,12 +45,18 @@ def test_convert_list_to_tuple_string_should_success(
4245
[
4346
("customer_id", ["id1"], "c.customer_id IN ('id1')"),
4447
("customer_id", ["id1", "id2"], "c.customer_id IN ('id1', 'id2')"),
45-
("customer_id", ["id1", "id2", "id3", "id4"],
46-
"c.customer_id IN ('id1', 'id2', 'id3', 'id4')"),
48+
(
49+
"customer_id",
50+
["id1", "id2", "id3", "id4"],
51+
"c.customer_id IN ('id1', 'id2', 'id3', 'id4')",
52+
),
4753
("id", ["id1"], "c.id IN ('id1')"),
4854
("id", ["id1", "id4"], "c.id IN ('id1', 'id4')"),
49-
("id", ["id1", "id2", "id3", "id4"],
50-
"c.id IN ('id1', 'id2', 'id3', 'id4')"),
55+
(
56+
"id",
57+
["id1", "id2", "id3", "id4"],
58+
"c.id IN ('id1', 'id2', 'id3', 'id4')",
59+
),
5160
],
5261
)
5362
def test_create_sql_in_condition(
@@ -67,6 +76,6 @@ def test_create_sql_in_condition(
6776
(""" SELECT * from c """, "SELECT * from c"),
6877
],
6978
)
70-
def test_get_string_without_empty_spaces(string, expected_string):
71-
string = get_string_without_empty_spaces(string)
79+
def test_remove_white_spaces(string, expected_string):
80+
string = remove_white_spaces(string)
7281
assert string == expected_string

utils/repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def create_sql_in_condition(field, values):
1515
return "c.{field} IN {list}".format(field=field, list=tuple_string)
1616

1717

18-
def get_string_without_empty_spaces(string: str):
18+
def remove_white_spaces(string: str):
1919
from re import sub
2020

2121
string = string.replace("\n", "")

0 commit comments

Comments
 (0)