Skip to content

Commit

Permalink
Increase granularity of DICOM IO Unit Tests (#29956)
Browse files Browse the repository at this point in the history
* Create HealthcareUtils file with shared resources

* revert

* Adding more granular test cases to missing DicomIO inputs.
  • Loading branch information
svetakvsundhar authored Jan 8, 2024
1 parent 6350339 commit 094eb7d
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions sdks/python/apache_beam/io/gcp/healthcare/dicomio_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ def test_Qido_search_small_buffer_flush(self, MockClient):

@patch("apache_beam.io.gcp.healthcare.dicomio.DicomApiHttpClient")
def test_param_dict_passing(self, MockClient):
input_dict = {}
input_dict = {}
input_dict['project_id'] = "test_project"
input_dict['region'] = "test_region"
Expand Down Expand Up @@ -257,7 +256,25 @@ def test_wrong_input_type(self, MockClient):
assert_that(results, equal_to([expected_invalid_dict]))

@patch("apache_beam.io.gcp.healthcare.dicomio.DicomApiHttpClient")
def test_missing_parameters(self, MockClient):
def test_missing_project_id(self, MockClient):
input_dict = {}
input_dict['dataset_id'] = "test_dataset"
input_dict['region'] = "test_region"

expected_invalid_dict = {}
expected_invalid_dict['result'] = []
expected_invalid_dict['status'] = 'Must have project_id in the dict.'
expected_invalid_dict['input'] = input_dict
expected_invalid_dict['success'] = False

mc = MockHttpClient()
MockClient.return_value = mc
with TestPipeline() as p:
results = (p | beam.Create([input_dict]) | DicomSearch())
assert_that(results, equal_to([expected_invalid_dict]))

@patch("apache_beam.io.gcp.healthcare.dicomio.DicomApiHttpClient")
def test_missing_dataset_id(self, MockClient):
input_dict = {}
input_dict['project_id'] = "test_project"
input_dict['region'] = "test_region"
Expand All @@ -274,6 +291,24 @@ def test_missing_parameters(self, MockClient):
results = (p | beam.Create([input_dict]) | DicomSearch())
assert_that(results, equal_to([expected_invalid_dict]))

@patch("apache_beam.io.gcp.healthcare.dicomio.DicomApiHttpClient")
def test_missing_region(self, MockClient):
input_dict = {}
input_dict['project_id'] = "test_project"
input_dict['dataset_id'] = "test_dataset"

expected_invalid_dict = {}
expected_invalid_dict['result'] = []
expected_invalid_dict['status'] = 'Must have region in the dict.'
expected_invalid_dict['input'] = input_dict
expected_invalid_dict['success'] = False

mc = MockHttpClient()
MockClient.return_value = mc
with TestPipeline() as p:
results = (p | beam.Create([input_dict]) | DicomSearch())
assert_that(results, equal_to([expected_invalid_dict]))

@patch("apache_beam.io.gcp.healthcare.dicomio.DicomApiHttpClient")
def test_client_search_notfound(self, MockClient):
input_dict = {}
Expand Down

0 comments on commit 094eb7d

Please sign in to comment.