Skip to content

Commit

Permalink
[DC-3352] Refactor integration test mock of ehr_submission_data_cutof…
Browse files Browse the repository at this point in the history
…f.get_affected_tables
  • Loading branch information
mark-velez committed Jul 18, 2023
1 parent d36f721 commit 1dcbf59
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ def setUpClass(cls):
cutoff_date = "2020-05-01"
cls.kwargs.update({'cutoff_date': cutoff_date})

# mocks the return value of get_affected_tables as we only want to loop through the
# visit_occurrence not all of the CDM tables
get_affected_tables_patch = patch(
'cdr_cleaner.cleaning_rules.ehr_submission_data_cutoff.get_affected_tables'
)
mock_get_affected_tables = get_affected_tables_patch.start()
mock_get_affected_tables.return_value = [common.VISIT_OCCURRENCE]
cls.addCleanup(mock_get_affected_tables.stop)

cls.rule_instance = EhrSubmissionDataCutoff(project_id, dataset_id,
sandbox_id)

Expand Down Expand Up @@ -75,16 +84,11 @@ def setUp(self):

super().setUp()

@patch('cdr_cleaner.cleaning_rules.ehr_submission_data_cutoff.get_affected_tables')
def test_ehr_submission_data_cutoff(self, mock_get_affected_tables):
def test_ehr_submission_data_cutoff(self):
"""
Validates pre conditions, tests execution, and post conditions based on the load
statements and the tables_and_counts variable.
"""
# mocks the return value of get_affected_tables as we only want to loop through the
# visit_occurrence not all of the CDM tables
mock_get_affected_tables.return_value = [common.VISIT_OCCURRENCE]

queries = []
visit_occurrence_tmpl = self.jinja_env.from_string("""
INSERT INTO `{{fq_dataset_name}}.{{cdm_table}}`
Expand Down

0 comments on commit 1dcbf59

Please sign in to comment.