-
Notifications
You must be signed in to change notification settings - Fork 0
TT-181 create method to find all projects with list of customer ids #266
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
Closed
eduardisrael
wants to merge
11
commits into
master
from
TT-181-create-method-to-find-all-projects-with-list-of-customer-ids
Closed
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c56d070
refactor: TT-180 add methods find_all_with_id_in_list and get_all_wit…
kellycastrof c9ae125
refactor: TT-180 changes in activity test
kellycastrof eaf5614
test: TT-180 add test validate list
Angeluz-07 0acdb5c
test: TT-180 add test convert list to tuple string
Angeluz-07 b0088b0
test: TT-180 add test create sql in condition
Angeluz-07 3f44227
test: TT-180 add test find_all, in progress
Angeluz-07 690af81
test: TT-180 add test find_all_with_id_in_list
Angeluz-07 98c883f
test: TT-180 remove unused imports, fix quotes
Angeluz-07 c94b511
refactor: TT-180 move convert_list_to_tuple_string and validate_list …
kellycastrof 267ef7f
feat : TT-181 create method to find all projects with a list of custo…
eduardisrael 79ace4b
feat: TT-181 change projects_model and projects_model_test functions …
eduardisrael 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
feat : TT-181 create method to find all projects with a list of custo…
…mers ids
- Loading branch information
commit 267ef7f00bceeed2caf07e740cde2bc1ea8da364
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
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,66 @@ | ||
| from unittest.mock import Mock, patch | ||
| import pytest | ||
|
|
||
| from commons.data_access_layer.database import EventContext | ||
| from time_tracker_api.projects.projects_model import ( | ||
| ProjectCosmosDBRepository, | ||
| ProjectCosmosDBModel, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "customer_ids_list,expected_result", | ||
| [ | ||
| (["id1"], "c.customer_id IN ('id1')"), | ||
| (["id1", "id2"], "c.customer_id IN ('id1', 'id2')"), | ||
| (["id1", "id2", "id3", "id4"], "c.customer_id IN ('id1', 'id2', 'id3', 'id4')"), | ||
| ], | ||
| ) | ||
| def test_create_sql_in_condition( | ||
| project_repository: ProjectCosmosDBRepository, | ||
| customer_ids_list, | ||
| expected_result, | ||
| ): | ||
| result = project_repository.create_sql_in_condition(customer_ids_list) | ||
| assert expected_result == result | ||
|
|
||
|
|
||
| @patch( | ||
| 'time_tracker_api.projects.projects_model.ProjectCosmosDBRepository.create_sql_condition_for_visibility' | ||
| ) | ||
| @patch( | ||
| 'time_tracker_api.projects.projects_model.ProjectCosmosDBRepository.create_sql_in_condition' | ||
| ) | ||
| @patch( | ||
| 'time_tracker_api.projects.projects_model.ProjectCosmosDBRepository.find_partition_key_value' | ||
| ) | ||
| def test_find_all_with_customer_id_in_list( | ||
| find_partition_key_value_mock, | ||
| create_sql_in_condition_mock, | ||
| create_sql_condition_for_visibility_mock, | ||
| event_context: EventContext, | ||
| project_repository: ProjectCosmosDBRepository, | ||
| ): | ||
| expected_item = { | ||
| 'customer_id': 'id1', | ||
| 'name': 'testing', | ||
| 'description': 'do some testing', | ||
| 'project_type_id': "id2", | ||
| 'tenant_id': 'tenantid1', | ||
| } | ||
|
|
||
| query_items_mock = Mock(return_value=[expected_item]) | ||
| project_repository.container = Mock() | ||
| project_repository.container.query_items = query_items_mock | ||
|
|
||
| result = project_repository.find_all_with_customer_id_in_list(event_context, []) | ||
|
|
||
| create_sql_condition_for_visibility_mock.assert_called_once() | ||
| create_sql_in_condition_mock.assert_called_once() | ||
| find_partition_key_value_mock.assert_called_once() | ||
| query_items_mock.assert_called_once() | ||
|
|
||
| assert len(result) == 1 | ||
| project = result[0] | ||
| assert isinstance(project, ProjectCosmosDBModel) | ||
| assert project.__dict__ == expected_item |
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.