From 1dcbf59d435a695f96d5ccda7e997070335a6b78 Mon Sep 17 00:00:00 2001 From: Mark Velez Date: Tue, 18 Jul 2023 15:48:08 -0400 Subject: [PATCH] [DC-3352] Refactor integration test mock of ehr_submission_data_cutoff.get_affected_tables --- .../ehr_submission_data_cutoff_test.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/integration_tests/data_steward/cdr_cleaner/cleaning_rules/ehr_submission_data_cutoff_test.py b/tests/integration_tests/data_steward/cdr_cleaner/cleaning_rules/ehr_submission_data_cutoff_test.py index cf9f7fb93c..9fc0c237b3 100644 --- a/tests/integration_tests/data_steward/cdr_cleaner/cleaning_rules/ehr_submission_data_cutoff_test.py +++ b/tests/integration_tests/data_steward/cdr_cleaner/cleaning_rules/ehr_submission_data_cutoff_test.py @@ -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) @@ -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}}`