示例#1
0
    def test_check_identifier_study(self):
        """Tests for check_find_identifier()."""
        ds = Dataset()
        ds.QueryRetrieveLevel = 'PATIENT'
        ds.PatientName = None
        study = StudyRootQueryRetrieveInformationModelFind

        msg = r"The Identifier's Query Retrieve Level value is invalid"
        with pytest.raises(db.InvalidIdentifier, match=msg):
            db._check_identifier(ds, study)

        ds.QueryRetrieveLevel = 'STUDY'
        db._check_identifier(ds, study)

        ds.QueryRetrieveLevel = 'SERIES'
        msg = (
            r"The Identifier is missing a unique key for the 'STUDY' level"
        )
        with pytest.raises(db.InvalidIdentifier, match=msg):
            db._check_identifier(ds, study)
        ds.PatientID = None
        with pytest.raises(db.InvalidIdentifier, match=msg):
            db._check_identifier(ds, study)

        ds.StudyInstanceUID = '12345'
        db._check_identifier(ds, study)
示例#2
0
    def test_check_identifier_param_study(self, level, identifier, pt, st):
        """Tests for check_identifier()."""
        ds = Dataset()
        ds.QueryRetrieveLevel = level
        for kw in identifier:
            setattr(ds, kw, None)

        model = StudyRootQueryRetrieveInformationModelFind
        if st:
            with pytest.raises(db.InvalidIdentifier, match=st):
                db._check_identifier(ds, model)
        else:
            db._check_identifier(ds, model)
示例#3
0
    def test_check_identifier_patient(self):
        """Tests for check_find_identifier()."""
        ds = Dataset()
        ds.QueryRetrieveLevel = "PATIENT"
        ds.PatientName = None
        patient = PatientRootQueryRetrieveInformationModelFind

        db._check_identifier(ds, patient)

        ds.QueryRetrieveLevel = "STUDY"
        msg = r"The Identifier is missing a unique key for the 'PATIENT' level"
        with pytest.raises(db.InvalidIdentifier, match=msg):
            db._check_identifier(ds, patient)

        ds.PatientID = "12345"
        db._check_identifier(ds, patient)
示例#4
0
 def test_check_identifier_raises(self):
     """Check raises if no QueryRetrieveLevel element."""
     model = PatientRootQueryRetrieveInformationModelFind
     msg = r"The Identifier contains no Query Retrieve Level element"
     with pytest.raises(db.InvalidIdentifier, match=msg):
         db._check_identifier(Dataset(), model)