-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from clearcare/feature/scan-query-all-in-table
Move query/scan functionality into table.py
- Loading branch information
Showing
4 changed files
with
117 additions
and
43 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,36 @@ | ||
from conftest import DYNAMODB_FIXTURES | ||
from cc_dynamodb3.mocks import mock_table_with_data | ||
from cc_dynamodb3.table import scan_all_in_table, query_all_in_table | ||
|
||
|
||
def test_scan_all_works_on_case_with_little_data(): | ||
data = DYNAMODB_FIXTURES['nps_survey'] | ||
data_by_profile_id = {i['profile_id']: i for i in data} | ||
table = mock_table_with_data('nps_survey', data) | ||
|
||
results = list(scan_all_in_table(table)) | ||
assert len(results) == 2 | ||
|
||
for result, metadata in results: | ||
item = data_by_profile_id[result.get('profile_id')] | ||
assert item['agency_id'] == result.get('agency_id') | ||
assert item['recommend_score'] == result.get('recommend_score') | ||
assert item.get('favorite') == result.get('favorite') | ||
|
||
|
||
def test_query_all_works_on_case_with_little_data(): | ||
data = DYNAMODB_FIXTURES['nps_survey'] | ||
data_by_profile_id = {i['profile_id']: i for i in data} | ||
table = mock_table_with_data('nps_survey', data) | ||
|
||
results = list(query_all_in_table(table, agency_id=1669)) | ||
assert len(results) == 2 | ||
|
||
for result, metadata in results: | ||
item = data_by_profile_id[result.get('profile_id')] | ||
assert item['agency_id'] == result.get('agency_id') | ||
assert item['recommend_score'] == result.get('recommend_score') | ||
assert item.get('favorite') == result.get('favorite') | ||
|
||
results = list(query_all_in_table(table, agency_id=1000)) | ||
assert len(results) == 0 |