Пример #1
0
    def _convert_program_assignment(self,
                                    ingest_assignment: StateProgramAssignment):
        """Converts an ingest_info proto StateProgramAssignment to a
        persistence entity"""

        program_assignment_builder = entities.StateProgramAssignment.builder()
        state_program_assignment.copy_fields_to_builder(
            program_assignment_builder, ingest_assignment, self.metadata)

        program_assignment_builder.referring_agent = \
            fn(lambda i: state_agent.convert(self.agents[i], self.metadata),
               'referring_agent_id',
               ingest_assignment)

        return program_assignment_builder.build()
    def testParseProgramAssignment(self):
        # Arrange
        ingest_program_assignment = ingest_info_pb2.StateProgramAssignment(
            participation_status="IN PROGRESS",
            discharge_reason="COMPLETED",
            state_program_assignment_id="PROGRAM_ASSIGNMENT_ID",
            referral_date="1/2/2111",
            start_date="1/3/2111",
            discharge_date="1/4/2111",
            program_id="PROGRAM_ID",
            program_location_id="LOCATION_ID",
            state_code="US_ND",
        )

        # Act
        program_assignment_builder = entities.StateProgramAssignment.builder()
        state_program_assignment.copy_fields_to_builder(
            program_assignment_builder, ingest_program_assignment,
            _EMPTY_METADATA)
        result = program_assignment_builder.build()

        # Assert
        expected_result = entities.StateProgramAssignment.new_with_defaults(
            participation_status=StateProgramAssignmentParticipationStatus.
            IN_PROGRESS,
            participation_status_raw_text="IN PROGRESS",
            discharge_reason=StateProgramAssignmentDischargeReason.COMPLETED,
            discharge_reason_raw_text="COMPLETED",
            external_id="PROGRAM_ASSIGNMENT_ID",
            referral_date=date(year=2111, month=1, day=2),
            start_date=date(year=2111, month=1, day=3),
            discharge_date=date(year=2111, month=1, day=4),
            program_id="PROGRAM_ID",
            program_location_id="LOCATION_ID",
            state_code="US_ND",
        )

        self.assertEqual(result, expected_result)