Skip to content
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

TDL-19801: Tap fetch data for sub-questions #62

Conversation

jtilala
Copy link
Contributor

@jtilala jtilala commented Jul 7, 2022

Description of change

  • Added field sub_questions for the Question group to resove issue #59.
  • Added function fetch_sub_questions to fetch data for sub-questions.

Manual QA steps

  • Run sync mode to check whether we are getting data for sub-questions or not

Risks

Rollback steps

  • revert this branch

Comment on lines 143 to 153
#If question group has no sub_questions, return blank list
if row['properties'].get('fields') == None :
return None

#Appending each sub-question to the list
for question in row['properties']['fields']:
sub_questions.append({
"question_id": question['id'],
"title": question['title'],
"ref": question['ref']
})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#If question group has no sub_questions, return blank list
if row['properties'].get('fields') == None :
return None
#Appending each sub-question to the list
for question in row['properties']['fields']:
sub_questions.append({
"question_id": question['id'],
"title": question['title'],
"ref": question['ref']
})
#Appending each sub-question to the list
for question in row['properties'].get('fields'):
sub_questions.append({
"question_id": question['id'],
"title": question['title'],
"ref": question['ref']
})

We can remove the if condition because for loop will not iterate on None or [] so no need to handle it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the "if" condition and used the "get" method as per suggestion.

Comment on lines 6 to 7
test_cases = [{'case1a': 'value1a', 'case1b': 'value1b', 'case1c': 'value1c', 'properties': {'description': 'Group question', 'case1': 'value1','case2':'value2', 'fields': [{'id': 'id1', 'title': 'title1', 'ref': 'ref1'}, {'id': 'id2','title': 'title2', 'ref': 'title2'}]}, 'type': 'group'}, {'case2a': 'value2a', 'case2b': 'value2b', 'case2c': 'value2c', 'properties': {'description': 'Group question', 'case3':'value3', 'case4':'value4'}, 'type': 'group'}]
expected_case = [{'question_id': 'id1', 'title': 'title1', 'ref': 'ref1'}, {'question_id': 'id2', 'title': 'title2', 'ref': 'title2'}]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Divide this line into multiline so every test scenario can be readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formated test_cases and expected_case in unit tests for better readability.

tap_typeform/streams.py Outdated Show resolved Hide resolved
Comment on lines 37 to 41
for test_case in test_cases :
if test_case ['properties'].get('fields'):
assert expected_case == fetch_sub_questions(test_case)
else:
assert [] == fetch_sub_questions(test_case)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If first assert fails, test will exit without executing next test. Please use parameterised unittests.

@jtilala jtilala requested review from RushiT0122 and dbshah1212 July 26, 2022 13:05
@RushiT0122 RushiT0122 self-requested a review July 28, 2022 07:47
@prijendev prijendev changed the base branch from master to crest-master August 29, 2022 08:14
@prijendev prijendev merged commit df040a5 into crest-master Aug 29, 2022
@prijendev prijendev mentioned this pull request Sep 2, 2022
somethingmorerelevant pushed a commit that referenced this pull request Sep 20, 2022
* Tdl 19964 add missing tap tester tests (#65)

* TDL-19964 Added missing tap-tester commits

* updated tap-tester tests

* updated bookmarks tap-tester test

* Updated and removed extra comments

* updated start date as per format

* updated pagination test case

* resolved review comments

* added new stream in tap-tester

* fixed the cci issues

* added missing assertion for all fields

* removed get_logger()

* added logger instead of print

* TDL-19957 Update dict based to class based implementation (#64)

* TDL-19957 update dict based to class based

* updated while condition

* updated while condition

* removed incremental_range from REQUIRED_CONFIG_KEYS

* updated discover and schema file

* updated to replication_key instead of keys

* updated schemas and added comments

* added unittests for code coverage

* added unittests for sync.py

* added parameterized in setup.py

* added parameterized in config.yml and updated unittests

* updated the replication key to list instead of a single key

* fixed the issue for Keyerror of form_id in answers stream

* updated unittests

* added configurable page size param

* handled page_size for 0 and updated unittests

* resolved bug fixes for pagination and removed incompleted_forms_only param

* added new stream unsubmitted landings

* resolved PR review comments

* added page_size in example config

* added back incremental_range in the tap-tester

* raised exc instead of fatal error message and updated unittests

* resolved PR comments

* fixed the issue when page_size not passed in config

* TDL-19801: Tap fetch data for sub-questions (#62)

* TDL-19801: Tap does not support fetching data for the questions nested within a Question Group.

* addressed the comments

* add unittest

* modify funciton comment

* formated test_case value in unittest

* formated expected_case

* Updated schema in questions.json

* resolved build fail error

* resolve build fail error

* updated unittest

* updated setup.py

* add parameterized

* change start date in start_date_test

* make change in bookmark test

* Updated unit test case.

* Updated schemas and keyerror.

Co-authored-by: Jay Tilala <[email protected]>
Co-authored-by: prijendev <[email protected]>

* TDL-19959 added missing fields (#63)

* added missing fields

* TDL-19957 update dict based to class based

* updated while condition

* updated while condition

* removed incremental_range from REQUIRED_CONFIG_KEYS

* TDL-19964 Added missing tap-tester commits

* updated discover and schema file

* updated tap-tester tests

* updated to replication_key instead of keys

* updated schemas and added comments

* added unittests for code coverage

* updated bookmarks tap-tester test

* added unittests for sync.py

* added parameterized in setup.py

* added parameterized in config.yml and updated unittests

* updated the replication key to list instead of a single key

* Updated and removed extra comments

* fixed the issue for Keyerror of form_id in answers stream

* updated unittests

* updated start date as per format

* added configurable page size param

* updated pagination test case

* handled page_size for 0 and updated unittests

* resolved review comments

* resolved bug fixes for pagination and removed incompleted_forms_only param

* updated array type schema

* added new stream unsubmitted landings

* added new stream in tap-tester

* updated indentation

* resolved PR review comments

* updated indentation to use 2 spaces

* added page_size in example config

* added back incremental_range in the tap-tester

* fixed the cci issues

* added missing fields to a dict

* added missing assertion for all fields

* updated comment

* raised exc instead of fatal error message and updated unittests

* removed get_logger()

* added logger instead of print

* Updated schema for questions.

* Removed duplicate assertion in all_fields test.

Co-authored-by: prijendev <[email protected]>

* Updated schema for answers stream.

Co-authored-by: namrata270998 <[email protected]>
Co-authored-by: jtilala <[email protected]>
Co-authored-by: Jay Tilala <[email protected]>
nitingaikwad1 pushed a commit that referenced this pull request Sep 29, 2022
* Tdl 19964 add missing tap tester tests (#65)

* TDL-19964 Added missing tap-tester commits

* updated tap-tester tests

* updated bookmarks tap-tester test

* Updated and removed extra comments

* updated start date as per format

* updated pagination test case

* resolved review comments

* added new stream in tap-tester

* fixed the cci issues

* added missing assertion for all fields

* removed get_logger()

* added logger instead of print

* TDL-19957 Update dict based to class based implementation (#64)

* TDL-19957 update dict based to class based

* updated while condition

* updated while condition

* removed incremental_range from REQUIRED_CONFIG_KEYS

* updated discover and schema file

* updated to replication_key instead of keys

* updated schemas and added comments

* added unittests for code coverage

* added unittests for sync.py

* added parameterized in setup.py

* added parameterized in config.yml and updated unittests

* updated the replication key to list instead of a single key

* fixed the issue for Keyerror of form_id in answers stream

* updated unittests

* added configurable page size param

* handled page_size for 0 and updated unittests

* resolved bug fixes for pagination and removed incompleted_forms_only param

* added new stream unsubmitted landings

* resolved PR review comments

* added page_size in example config

* added back incremental_range in the tap-tester

* raised exc instead of fatal error message and updated unittests

* resolved PR comments

* fixed the issue when page_size not passed in config

* TDL-19801: Tap fetch data for sub-questions (#62)

* TDL-19801: Tap does not support fetching data for the questions nested within a Question Group.

* addressed the comments

* add unittest

* modify funciton comment

* formated test_case value in unittest

* formated expected_case

* Updated schema in questions.json

* resolved build fail error

* resolve build fail error

* updated unittest

* updated setup.py

* add parameterized

* change start date in start_date_test

* make change in bookmark test

* Updated unit test case.

* Updated schemas and keyerror.

Co-authored-by: Jay Tilala <[email protected]>
Co-authored-by: prijendev <[email protected]>

* TDL-19959 added missing fields (#63)

* added missing fields

* TDL-19957 update dict based to class based

* updated while condition

* updated while condition

* removed incremental_range from REQUIRED_CONFIG_KEYS

* TDL-19964 Added missing tap-tester commits

* updated discover and schema file

* updated tap-tester tests

* updated to replication_key instead of keys

* updated schemas and added comments

* added unittests for code coverage

* updated bookmarks tap-tester test

* added unittests for sync.py

* added parameterized in setup.py

* added parameterized in config.yml and updated unittests

* updated the replication key to list instead of a single key

* Updated and removed extra comments

* fixed the issue for Keyerror of form_id in answers stream

* updated unittests

* updated start date as per format

* added configurable page size param

* updated pagination test case

* handled page_size for 0 and updated unittests

* resolved review comments

* resolved bug fixes for pagination and removed incompleted_forms_only param

* updated array type schema

* added new stream unsubmitted landings

* added new stream in tap-tester

* updated indentation

* resolved PR review comments

* updated indentation to use 2 spaces

* added page_size in example config

* added back incremental_range in the tap-tester

* fixed the cci issues

* added missing fields to a dict

* added missing assertion for all fields

* updated comment

* raised exc instead of fatal error message and updated unittests

* removed get_logger()

* added logger instead of print

* Updated schema for questions.

* Removed duplicate assertion in all_fields test.

Co-authored-by: prijendev <[email protected]>

* Updated schema for answers stream.

* update version and changelog

* changelog update for v2.0.0

* changelog update for v2.0.0

* minor changelog update

Co-authored-by: namrata270998 <[email protected]>
Co-authored-by: jtilala <[email protected]>
Co-authored-by: Jay Tilala <[email protected]>
Co-authored-by: prijendev <[email protected]>
Co-authored-by: kethan1122 <[email protected]>
Co-authored-by: rdeshmukh15 <[email protected]>
@kethan1122 kethan1122 deleted the TDL-19801-Tap-Does-Not-Support-Fetching-Data-For-The-Questions-Nested-Within-A-Question-Group branch April 28, 2023 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants