Beispiel #1
0
 def test_removeSeosFromViolationIds_unexpectedFormat(self):
     with pytest.raises(ValueError):
         sv = schema.StateSupervisionViolation(external_id='bad_id')
         sp = schema.StateSupervisionPeriod(
             supervision_violation_entries=[sv])
         ss = schema.StateSupervisionSentence(supervision_periods=[sp])
         sg = schema.StateSentenceGroup(supervision_sentences=[ss])
         p = schema.StatePerson(sentence_groups=[sg])
         remove_suffix_from_violation_ids([p])
Beispiel #2
0
 def test_removeSeosFromViolationIds_unexpectedFormat(self) -> None:
     with pytest.raises(ValueError) as e:
         sv = schema.StateSupervisionViolation(external_id="bad_id")
         sp = schema.StateSupervisionPeriod(
             supervision_violation_entries=[sv],
             status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
         )
         ss = schema.StateSupervisionSentence(supervision_periods=[sp])
         sg = schema.StateSentenceGroup(supervision_sentences=[ss])
         p = schema.StatePerson(sentence_groups=[sg])
         remove_suffix_from_violation_ids([p])
     self.assertEqual(
         str(e.value),
         "Unexpected id format [bad_id] for [StateSupervisionViolation(external_id=bad_id)]",
     )
Beispiel #3
0
    def test_removeSeosFromViolationIds(self):
        svr = schema.StateSupervisionViolationResponse(
            external_id='DOC-CYC-VSN1-SEO-FSO')
        sv = schema.StateSupervisionViolation(
            external_id='DOC-CYC-VSN1-SEO-FSO',
            supervision_violation_responses=[svr])
        svr_2 = schema.StateSupervisionViolationResponse(
            external_id='DOC-CYC-VSN1-SEO-FSO')
        sv_2 = schema.StateSupervisionViolation(
            external_id='DOC-CYC-VSN1-SEO-FSO',
            supervision_violation_responses=[svr_2])
        sp = schema.StateSupervisionPeriod(
            supervision_violation_entries=[sv, sv_2])
        ss = schema.StateSupervisionSentence(supervision_periods=[sp])
        sg = schema.StateSentenceGroup(supervision_sentences=[ss])
        p = schema.StatePerson(sentence_groups=[sg])

        expected_svr = StateSupervisionViolationResponse.new_with_defaults(
            external_id='DOC-CYC-VSN1')
        expected_sv = StateSupervisionViolation.new_with_defaults(
            external_id='DOC-CYC-VSN1',
            supervision_violation_responses=[expected_svr])
        expected_svr_2 = attr.evolve(expected_svr)
        expected_sv_2 = attr.evolve(
            expected_sv,
            supervision_violation_responses=[expected_svr_2])
        expected_sp = StateSupervisionPeriod.new_with_defaults(
            supervision_violation_entries=[expected_sv, expected_sv_2])
        expected_ss = StateSupervisionSentence.new_with_defaults(
            supervision_periods=[expected_sp])
        expected_sg = StateSentenceGroup.new_with_defaults(
            supervision_sentences=[expected_ss])
        expected_p = StatePerson.new_with_defaults(
            sentence_groups=[expected_sg])

        remove_suffix_from_violation_ids([p])
        self.assertEqual(expected_p, self.to_entity(p))
 def perform_match_preprocessing(
         self, ingested_persons: List[schema.StatePerson]):
     logging.info("[Entity matching] Pre-processing: Remove SEOs from "
                  "violation ids")
     remove_suffix_from_violation_ids(ingested_persons)
Beispiel #5
0
    def test_removeSeosFromViolationIds(self) -> None:
        svr = schema.StateSupervisionViolationResponse(
            state_code=_STATE_CODE, external_id="DOC-CYC-VSN1-SEO-FSO")
        sv = schema.StateSupervisionViolation(
            state_code=_STATE_CODE,
            external_id="DOC-CYC-VSN1-SEO-FSO",
            supervision_violation_responses=[svr],
        )
        svr_2 = schema.StateSupervisionViolationResponse(
            state_code=_STATE_CODE, external_id="DOC-CYC-VSN1-SEO-FSO")
        sv_2 = schema.StateSupervisionViolation(
            state_code=_STATE_CODE,
            external_id="DOC-CYC-VSN1-SEO-FSO",
            supervision_violation_responses=[svr_2],
        )
        sp = schema.StateSupervisionPeriod(
            state_code=_STATE_CODE,
            supervision_violation_entries=[sv, sv_2],
            status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
        )
        ss = schema.StateSupervisionSentence(
            state_code=_STATE_CODE,
            supervision_periods=[sp],
            status=StateSentenceStatus.PRESENT_WITHOUT_INFO,
        )
        sg = schema.StateSentenceGroup(
            state_code=_STATE_CODE,
            status=StateSentenceStatus.PRESENT_WITHOUT_INFO,
            supervision_sentences=[ss],
        )
        p = schema.StatePerson(state_code=_STATE_CODE, sentence_groups=[sg])

        expected_svr = StateSupervisionViolationResponse.new_with_defaults(
            state_code=_STATE_CODE, external_id="DOC-CYC-VSN1")
        expected_sv = StateSupervisionViolation.new_with_defaults(
            state_code=_STATE_CODE,
            external_id="DOC-CYC-VSN1",
            supervision_violation_responses=[expected_svr],
        )
        expected_svr_2 = attr.evolve(expected_svr)
        expected_sv_2 = attr.evolve(
            expected_sv, supervision_violation_responses=[expected_svr_2])
        expected_sp = StateSupervisionPeriod.new_with_defaults(
            state_code=_STATE_CODE,
            supervision_violation_entries=[expected_sv, expected_sv_2],
            status=StateSupervisionPeriodStatus.PRESENT_WITHOUT_INFO,
        )
        expected_ss = StateSupervisionSentence.new_with_defaults(
            state_code=_STATE_CODE,
            supervision_periods=[expected_sp],
            status=StateSentenceStatus.PRESENT_WITHOUT_INFO,
        )
        expected_sg = StateSentenceGroup.new_with_defaults(
            state_code=_STATE_CODE,
            status=StateSentenceStatus.PRESENT_WITHOUT_INFO,
            supervision_sentences=[expected_ss],
        )
        expected_p = StatePerson.new_with_defaults(
            state_code=_STATE_CODE, sentence_groups=[expected_sg])

        remove_suffix_from_violation_ids([p])
        self.assertEqual(expected_p, self.to_entity(p))