Skip to content

Commit

Permalink
Merge pull request #20 from ImageMarkup/isic-166-require-dct
Browse files Browse the repository at this point in the history
  • Loading branch information
danlamanna authored Nov 28, 2023
2 parents 26bca87 + d64d1b4 commit bf0dd39
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 47 deletions.
20 changes: 0 additions & 20 deletions isic_metadata/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,26 +236,6 @@ def validate_melanoma_fields(cls, v, info: ValidationInfo):
raise ValueError(f"A non-melanoma {info.data['diagnosis']} cannot exist.")
return v

@field_validator("diagnosis_confirm_type")
@classmethod
def validate_non_histopathology_diagnoses(cls, v, info: ValidationInfo):
# TODO: renable this after https://github.com/ImageMarkup/tracker/issues/141 is fixed.
# if not info.data.get("diagnosis"):
# raise ValueError("Diagnosis confirm type requires a diagnosis.")

if info.data.get("benign_malignant"):
if v != "histopathology" and info.data["benign_malignant"] in [
BenignMalignantEnum.malignant,
BenignMalignantEnum.indeterminate_benign,
BenignMalignantEnum.indeterminate_malignant,
BenignMalignantEnum.indeterminate,
]:
raise ValueError(
f'{info.data["benign_malignant"]} is incompatible with diagnosis_confirm_type: {v}' # noqa: E501
)

return v

@field_validator("dermoscopic_type")
@classmethod
def validate_dermoscopic_fields(cls, v, info: ValidationInfo):
Expand Down
27 changes: 0 additions & 27 deletions tests/test_dependent_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from pydantic import ValidationError
import pytest

from isic_metadata.fields import BenignMalignantEnum
from isic_metadata.metadata import MetadataRow


Expand Down Expand Up @@ -62,32 +61,6 @@ def test_diagnosis_confirm_type_requires_diagnosis():
MetadataRow(diagnosis="melanoma", diagnosis_confirm_type="histopathology")


@pytest.mark.parametrize(
"benign_malignant",
[
BenignMalignantEnum.malignant,
BenignMalignantEnum.indeterminate_benign,
BenignMalignantEnum.indeterminate_malignant,
BenignMalignantEnum.indeterminate,
],
)
def test_diagnosis_confirm_type_must_be_histopathology(benign_malignant):
with pytest.raises(ValidationError) as excinfo:
MetadataRow(
benign_malignant=benign_malignant,
diagnosis="solar lentigo",
diagnosis_confirm_type="single image expert consensus",
)
assert len(excinfo.value.errors()) == 1
assert excinfo.value.errors()[0]["loc"][0] == "diagnosis_confirm_type"

MetadataRow(
benign_malignant=benign_malignant,
diagnosis="solar lentigo",
diagnosis_confirm_type="histopathology",
)


def test_dermoscopic_type_requires_image_type_dermoscopic():
with pytest.raises(ValidationError) as excinfo:
MetadataRow(dermoscopic_type="contact polarized")
Expand Down

0 comments on commit bf0dd39

Please sign in to comment.