Skip to content

Commit

Permalink
Commenting out DICOM verification engine intergration test to see if …
Browse files Browse the repository at this point in the history
…that is still the cause of unit test hangup
  • Loading branch information
niwilso committed Jul 13, 2023
1 parent 5ae889f commit b54cd15
Showing 1 changed file with 52 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
"""Integration test for dicom_image_pii_verify_engine
Note we are not checking exact pixel data for the returned image
because that is covered by testing of the "verify" function in
the original parent ImagePiiVerifyEngine class.
"""
import PIL
import pydicom

from presidio_image_redactor import DicomImagePiiVerifyEngine, BboxProcessor

PADDING_WIDTH = 25

def test_verify_correctly(
get_mock_dicom_instance: pydicom.dataset.FileDataset,
get_mock_dicom_verify_results: dict,
):
"""Test the verify_dicom_instance function.
Args:
get_mock_dicom_instance (pydicom.dataset.FileDataset): Loaded DICOM.
get_mock_dicom_verify_results (dict): Dictionary with loaded results.
"""
# Assign
expected_ocr_results_labels = []
for item in get_mock_dicom_verify_results["ocr_results_formatted"]:
expected_ocr_results_labels.append(item["label"])

# Act
test_image_verify, test_ocr_results, _ = DicomImagePiiVerifyEngine().verify_dicom_instance(
instance=get_mock_dicom_instance,
padding_width=PADDING_WIDTH,
display_image=True,
ocr_kwargs=None
)
test_ocr_results_formatted = BboxProcessor().get_bboxes_from_ocr_results(
ocr_results=test_ocr_results
)

# Check most OCR results (labels) are the same
# Don't worry about position since that is implied in analyzer results
test_ocr_results_labels = []
for item in test_ocr_results_formatted:
test_ocr_results_labels.append(item["label"])
test_common_labels = set(expected_ocr_results_labels).intersection(
set(test_ocr_results_labels)
)
test_all_labels = set(expected_ocr_results_labels).union(set(test_ocr_results_labels))

# Assert
assert type(test_image_verify) == PIL.Image.Image
assert len(test_common_labels) / len(test_all_labels) >= 0.5
# """Integration test for dicom_image_pii_verify_engine

# Note we are not checking exact pixel data for the returned image
# because that is covered by testing of the "verify" function in
# the original parent ImagePiiVerifyEngine class.
# """
# import PIL
# import pydicom

# from presidio_image_redactor import DicomImagePiiVerifyEngine, BboxProcessor

# PADDING_WIDTH = 25

# def test_verify_correctly(
# get_mock_dicom_instance: pydicom.dataset.FileDataset,
# get_mock_dicom_verify_results: dict,
# ):
# """Test the verify_dicom_instance function.

# Args:
# get_mock_dicom_instance (pydicom.dataset.FileDataset): Loaded DICOM.
# get_mock_dicom_verify_results (dict): Dictionary with loaded results.
# """
# # Assign
# expected_ocr_results_labels = []
# for item in get_mock_dicom_verify_results["ocr_results_formatted"]:
# expected_ocr_results_labels.append(item["label"])

# # Act
# test_image_verify, test_ocr_results, _ = DicomImagePiiVerifyEngine().verify_dicom_instance(
# instance=get_mock_dicom_instance,
# padding_width=PADDING_WIDTH,
# display_image=True,
# ocr_kwargs=None
# )
# test_ocr_results_formatted = BboxProcessor().get_bboxes_from_ocr_results(
# ocr_results=test_ocr_results
# )

# # Check most OCR results (labels) are the same
# # Don't worry about position since that is implied in analyzer results
# test_ocr_results_labels = []
# for item in test_ocr_results_formatted:
# test_ocr_results_labels.append(item["label"])
# test_common_labels = set(expected_ocr_results_labels).intersection(
# set(test_ocr_results_labels)
# )
# test_all_labels = set(expected_ocr_results_labels).union(set(test_ocr_results_labels))

# # Assert
# assert type(test_image_verify) == PIL.Image.Image
# assert len(test_common_labels) / len(test_all_labels) >= 0.5

0 comments on commit b54cd15

Please sign in to comment.