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

Increase granularity of DICOM IO Unit Tests #29956

Merged
merged 9 commits into from
Jan 8, 2024
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 = {}
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for the clean up

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
Loading