-
Notifications
You must be signed in to change notification settings - Fork 0
Tt 185 find all method in time entries #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
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 031b883
test: TT-185 query_builder tests
kellycastrof 262ace0
test: TT-185 add test methods for TimeEntryQueryBuilder and new funct…
kellycastrof 7914fdf
build: TT-199 build(deps): bump jinja2 in /requirements/time_tracker…
dependabot[bot] 2b57549
refactor: TT-185 create SQLBuilder, TimeEntryQueryBuilder and find_al…
kellycastrof 7606663
test: TT-185 query_builder tests
kellycastrof f1fc8a6
test: TT-185 add test methods for TimeEntryQueryBuilder and new funct…
kellycastrof be72ff8
refactor: TT-185 rename get_string_without_empty_spaces to remove_whi…
kellycastrof 3401b39
refactor: TT-185 add time_entries_id in condition
kellycastrof 2342ce9
refactor: TT-185 delete empty lines
kellycastrof 5358c40
refactor: TT-185 delete isintance validation
kellycastrof a403edb
refactor: TT-185 improve function remove_white_spaces
Angeluz-07 d538899
refactor: TT-185 change column to columns
Angeluz-07 06cbca7
refactor: TT-185 add more scenarios to test_add_sql_in_condition_shou…
Angeluz-07 a1331fc
refactor: TT-185 add more scenarios to test__build_where_should_retur…
Angeluz-07 c44f20e
refactor: TT-185 improve test_TimeEntryQueryBuilder_is_subclass_Cosmo…
Angeluz-07 f17d841
refactor: TT-185 rename args in TimeEntriesRepository
Angeluz-07 be6e9b1
refactor: TT-185 change the scenarios in test_add_sql_date_range_cond…
kellycastrof File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: TT-185 add test methods for TimeEntryQueryBuilder and new funct…
…ion in repository
- Loading branch information
commit f1fc8a6d9de36bb457ecfc144dec42d343e3c9cf
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
tests/time_tracker_api/time_entries/time_entries_query_builder_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import pytest | ||
| from unittest.mock import patch | ||
| from utils.query_builder import CosmosDBQueryBuilder | ||
| from time_tracker_api.time_entries.time_entries_query_builder import ( | ||
| TimeEntryQueryBuilder, | ||
| ) | ||
| from utils.repository import get_string_without_empty_spaces | ||
|
|
||
|
|
||
| def test_TimeEntryQueryBuilder_is_subclass_CosmosDBQueryBuilder(): | ||
| query_builder = CosmosDBQueryBuilder() | ||
| time_entries_query_builder = TimeEntryQueryBuilder() | ||
|
|
||
| assert issubclass(TimeEntryQueryBuilder, CosmosDBQueryBuilder) == True | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "start_date,end_date,expected_params", | ||
| [ | ||
| ( | ||
| "2021-03-19T05:07:00.000Z", | ||
| "2021-03-25T10:00:00.000Z", | ||
| [ | ||
| {"name": "@start_date", "value": "2021-03-19T05:07:00.000Z"}, | ||
| {"name": "@end_date", "value": "2021-03-25T10:00:00.000Z"}, | ||
| ], | ||
| ), | ||
| ( | ||
| "2021-02-10T05:08:00.000Z", | ||
| "2021-03-20T11:00:00.000Z", | ||
| [ | ||
| {"name": "@start_date", "value": "2021-02-10T05:08:00.000Z"}, | ||
| {"name": "@end_date", "value": "2021-03-20T11:00:00.000Z"}, | ||
| ], | ||
| ), | ||
| ( | ||
| "2021-01-02T05:09:00.000Z", | ||
| "2021-01-26T12:00:00.000Z", | ||
| [ | ||
| {"name": "@start_date", "value": "2021-01-02T05:09:00.000Z"}, | ||
| {"name": "@end_date", "value": "2021-01-26T12:00:00.000Z"}, | ||
| ], | ||
| ), | ||
| ], | ||
| ) | ||
| def test_add_sql_date_range_condition_should_update_where_list( | ||
| start_date, end_date, expected_params | ||
| ): | ||
| time_entry_query_builder = ( | ||
| TimeEntryQueryBuilder().add_sql_date_range_condition( | ||
| (start_date, end_date) | ||
| ) | ||
| ) | ||
|
|
||
| assert len(time_entry_query_builder.where_conditions) == 1 | ||
| assert len(time_entry_query_builder.parameters) == len(expected_params) | ||
| assert time_entry_query_builder.get_parameters() == expected_params | ||
|
|
||
|
|
||
| def test_build_with_add_sql_date_range_condition(): | ||
| time_entry_query_builder = ( | ||
| TimeEntryQueryBuilder() | ||
| .add_sql_date_range_condition( | ||
| ("2021-03-19T05:00:00.000Z", "2021-03-20T10:00:00.000Z") | ||
| ) | ||
| .build() | ||
| ) | ||
|
|
||
| expected_query = """ | ||
| SELECT * FROM c | ||
| WHERE ((c.start_date BETWEEN @start_date AND @end_date) OR | ||
| (c.end_date BETWEEN @start_date AND @end_date)) | ||
| """ | ||
| query = time_entry_query_builder.get_query() | ||
|
|
||
| assert get_string_without_empty_spaces( | ||
| query | ||
| ) == get_string_without_empty_spaces(expected_query) | ||
|
|
||
| assert len(time_entry_query_builder.where_conditions) == 1 | ||
| assert len(time_entry_query_builder.get_parameters()) == 2 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.