This is an automated email from the ASF dual-hosted git repository.
yhu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new 094eb7dc5d7 Increase granularity of DICOM IO Unit Tests (#29956)
094eb7dc5d7 is described below
commit 094eb7dc5d7bc9f3de9ef57e8d764f0d8defe037
Author: Svetak Sundhar <[email protected]>
AuthorDate: Mon Jan 8 23:09:05 2024 +0000
Increase granularity of DICOM IO Unit Tests (#29956)
* Create HealthcareUtils file with shared resources
* revert
* Adding more granular test cases to missing DicomIO inputs.
---
.../apache_beam/io/gcp/healthcare/dicomio_test.py | 39 ++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
diff --git a/sdks/python/apache_beam/io/gcp/healthcare/dicomio_test.py
b/sdks/python/apache_beam/io/gcp/healthcare/dicomio_test.py
index 812f2585768..30e5d4c0f77 100644
--- a/sdks/python/apache_beam/io/gcp/healthcare/dicomio_test.py
+++ b/sdks/python/apache_beam/io/gcp/healthcare/dicomio_test.py
@@ -211,7 +211,6 @@ class TestDicomSearch(unittest.TestCase):
@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"
@@ -257,7 +256,25 @@ class TestDicomSearch(unittest.TestCase):
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"
@@ -274,6 +291,24 @@ class TestDicomSearch(unittest.TestCase):
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 = {}