Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
eb62162
refactor: TT-185 create SQLBuilder, TimeEntryQueryBuilder and find_al…
kellycastrof Mar 24, 2021
031b883
test: TT-185 query_builder tests
kellycastrof Mar 25, 2021
262ace0
test: TT-185 add test methods for TimeEntryQueryBuilder and new funct…
kellycastrof Mar 26, 2021
7914fdf
build: TT-199 build(deps): bump jinja2 in /requirements/time_tracker…
dependabot[bot] Mar 26, 2021
2b57549
refactor: TT-185 create SQLBuilder, TimeEntryQueryBuilder and find_al…
kellycastrof Mar 24, 2021
7606663
test: TT-185 query_builder tests
kellycastrof Mar 25, 2021
f1fc8a6
test: TT-185 add test methods for TimeEntryQueryBuilder and new funct…
kellycastrof Mar 26, 2021
be72ff8
refactor: TT-185 rename get_string_without_empty_spaces to remove_whi…
kellycastrof Mar 26, 2021
3401b39
refactor: TT-185 add time_entries_id in condition
kellycastrof Mar 26, 2021
2342ce9
refactor: TT-185 delete empty lines
kellycastrof Mar 26, 2021
5358c40
refactor: TT-185 delete isintance validation
kellycastrof Mar 26, 2021
a403edb
refactor: TT-185 improve function remove_white_spaces
Angeluz-07 Mar 26, 2021
d538899
refactor: TT-185 change column to columns
Angeluz-07 Mar 26, 2021
06cbca7
refactor: TT-185 add more scenarios to test_add_sql_in_condition_shou…
Angeluz-07 Mar 26, 2021
a1331fc
refactor: TT-185 add more scenarios to test__build_where_should_retur…
Angeluz-07 Mar 26, 2021
c44f20e
refactor: TT-185 improve test_TimeEntryQueryBuilder_is_subclass_Cosmo…
Angeluz-07 Mar 26, 2021
f17d841
refactor: TT-185 rename args in TimeEntriesRepository
Angeluz-07 Mar 26, 2021
be6e9b1
refactor: TT-185 change the scenarios in test_add_sql_date_range_cond…
kellycastrof Mar 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: TT-185 rename get_string_without_empty_spaces to remove_whi…
…te_spaces
  • Loading branch information
kellycastrof committed Mar 26, 2021
commit be72ff8a08a3713cd74c4d2ac1e83693daaf1eb9
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from time_tracker_api.time_entries.time_entries_query_builder import (
TimeEntryQueryBuilder,
)
from utils.repository import get_string_without_empty_spaces
from utils.repository import remove_white_spaces


def test_TimeEntryQueryBuilder_is_subclass_CosmosDBQueryBuilder():
Expand Down Expand Up @@ -73,9 +73,7 @@ def test_build_with_add_sql_date_range_condition():
"""
query = time_entry_query_builder.get_query()

assert get_string_without_empty_spaces(
query
) == get_string_without_empty_spaces(expected_query)
assert remove_white_spaces(query) == remove_white_spaces(expected_query)

assert len(time_entry_query_builder.where_conditions) == 1
assert len(time_entry_query_builder.get_parameters()) == 2
10 changes: 4 additions & 6 deletions tests/utils/query_builder_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from unittest.mock import patch
from utils.query_builder import CosmosDBQueryBuilder
from utils.repository import get_string_without_empty_spaces
from utils.repository import remove_white_spaces
import pytest


Expand Down Expand Up @@ -234,9 +234,7 @@ def test_build_with_all_calls_return_query_with_all_conditions():
LIMIT @limit
"""

assert get_string_without_empty_spaces(
query
) == get_string_without_empty_spaces(expected_query)
assert remove_white_spaces(query) == remove_white_spaces(expected_query)

assert len(query_builder.get_parameters()) > 0
assert len(query_builder.where_conditions) > 0
Expand All @@ -258,8 +256,8 @@ def test_build_with_empty_and_None_attributes_return_query_select_all():
query = query_builder.get_query()

expected_query = """SELECT * FROM c"""
query = get_string_without_empty_spaces(query)
expected_query = get_string_without_empty_spaces(expected_query)
query = remove_white_spaces(query)
expected_query = remove_white_spaces(expected_query)

assert query == expected_query
assert len(query_builder.get_parameters()) == 0
Expand Down
25 changes: 17 additions & 8 deletions tests/utils/repository_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from unittest.mock import patch
from utils.repository import convert_list_to_tuple_string, create_sql_in_condition
from utils.repository import get_string_without_empty_spaces
from utils.repository import (
convert_list_to_tuple_string,
create_sql_in_condition,
remove_white_spaces,
)
import pytest


Expand Down Expand Up @@ -42,12 +45,18 @@ def test_convert_list_to_tuple_string_should_success(
[
("customer_id", ["id1"], "c.customer_id IN ('id1')"),
("customer_id", ["id1", "id2"], "c.customer_id IN ('id1', 'id2')"),
("customer_id", ["id1", "id2", "id3", "id4"],
"c.customer_id IN ('id1', 'id2', 'id3', 'id4')"),
(
"customer_id",
["id1", "id2", "id3", "id4"],
"c.customer_id IN ('id1', 'id2', 'id3', 'id4')",
),
("id", ["id1"], "c.id IN ('id1')"),
("id", ["id1", "id4"], "c.id IN ('id1', 'id4')"),
("id", ["id1", "id2", "id3", "id4"],
"c.id IN ('id1', 'id2', 'id3', 'id4')"),
(
"id",
["id1", "id2", "id3", "id4"],
"c.id IN ('id1', 'id2', 'id3', 'id4')",
),
],
)
def test_create_sql_in_condition(
Expand All @@ -67,6 +76,6 @@ def test_create_sql_in_condition(
(""" SELECT * from c """, "SELECT * from c"),
],
)
def test_get_string_without_empty_spaces(string, expected_string):
string = get_string_without_empty_spaces(string)
def test_remove_white_spaces(string, expected_string):
string = remove_white_spaces(string)
assert string == expected_string
2 changes: 1 addition & 1 deletion utils/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def create_sql_in_condition(field, values):
return "c.{field} IN {list}".format(field=field, list=tuple_string)


def get_string_without_empty_spaces(string: str):
def remove_white_spaces(string: str):
from re import sub

string = string.replace("\n", "")
Expand Down