Exemple #1
0
    def test_add_person_characteristics_IncludeExternalId(self):
        person = StatePerson.new_with_defaults(
            state_code='US_MO',
            person_id=12345,
            birthdate=date(1984, 8, 31),
            gender=Gender.FEMALE,
            races=[StatePersonRace.new_with_defaults()],
            ethnicities=[StatePersonEthnicity.new_with_defaults()],
            external_ids=[
                StatePersonExternalId.new_with_defaults(external_id='SID1341',
                                                        id_type='US_MO_DOC',
                                                        state_code='US_MO')
            ])

        event_date = date(2010, 9, 1)

        person_metadata = PersonMetadata()

        updated_characteristics = person_characteristics(
            person, event_date, person_metadata, 'supervision')

        expected_output = {
            'age_bucket': '25-29',
            'gender': Gender.FEMALE,
            'person_id': person.person_id,
            'person_external_id': 'SID1341'
        }

        self.assertEqual(updated_characteristics, expected_output)
Exemple #2
0
    def test_add_person_characteristics_IncludeExternalId(self):
        person = StatePerson.new_with_defaults(
            state_code="US_XX",
            person_id=12345,
            birthdate=date(1984, 8, 31),
            gender=Gender.FEMALE,
            races=[StatePersonRace.new_with_defaults(state_code="US_XX", )],
            ethnicities=[
                StatePersonEthnicity.new_with_defaults(state_code="US_XX", )
            ],
            external_ids=[
                StatePersonExternalId.new_with_defaults(external_id="DOC1341",
                                                        id_type="US_XX_DOC",
                                                        state_code="US_XX"),
                StatePersonExternalId.new_with_defaults(external_id="SID9889",
                                                        id_type="US_XX_SID",
                                                        state_code="US_XX"),
            ],
        )

        event_date = date(2010, 9, 1)

        person_metadata = PersonMetadata()

        updated_characteristics = person_characteristics(
            person, event_date, person_metadata, "test_pipeline")

        expected_output = {
            "age_bucket": "25-29",
            "gender": Gender.FEMALE,
            "person_id": person.person_id,
            "person_external_id": "DOC1341",
        }

        self.assertEqual(updated_characteristics, expected_output)
Exemple #3
0
    def test_add_person_characteristics_RaceEthnicity(self):
        person = StatePerson.new_with_defaults(
            state_code='US_XX',
            person_id=12345,
            birthdate=date(1984, 8, 31),
            gender=Gender.FEMALE,
            races=[StatePersonRace.new_with_defaults(race=Race.ASIAN)],
            ethnicities=[
                StatePersonEthnicity.new_with_defaults(
                    ethnicity=Ethnicity.HISPANIC)
            ])

        event_date = date(2010, 9, 1)

        person_metadata = PersonMetadata(
            prioritized_race_or_ethnicity='HISPANIC')

        updated_characteristics = person_characteristics(
            person, event_date, person_metadata, 'pipeline')

        expected_output = {
            'age_bucket': '25-29',
            'race': [Race.ASIAN],
            'gender': Gender.FEMALE,
            'ethnicity': [Ethnicity.HISPANIC],
            'person_id': person.person_id,
            'prioritized_race_or_ethnicity': 'HISPANIC'
        }

        self.assertEqual(updated_characteristics, expected_output)
Exemple #4
0
    def test_add_person_characteristics_MultipleRaces(self):
        person = StatePerson.new_with_defaults(
            person_id=12345,
            birthdate=date(1984, 8, 31),
            gender=Gender.FEMALE,
            races=[
                StatePersonRace.new_with_defaults(race=Race.ASIAN),
                StatePersonRace.new_with_defaults(race=Race.BLACK)
            ])

        event_date = date(2010, 9, 1)

        person_metadata = PersonMetadata(prioritized_race_or_ethnicity='BLACK')

        updated_characteristics = person_characteristics(
            person, event_date, person_metadata, 'pipeline')

        expected_output = {
            'age_bucket': '25-29',
            'race': [Race.ASIAN, Race.BLACK],
            'gender': Gender.FEMALE,
            'person_id': person.person_id,
            'prioritized_race_or_ethnicity': 'BLACK'
        }

        self.assertEqual(updated_characteristics, expected_output)
Exemple #5
0
    def test_add_person_characteristics_NoAttributes(self):
        person = StatePerson.new_with_defaults(person_id=12345)

        event_date = date(2010, 9, 1)

        person_metadata = PersonMetadata()

        updated_characteristics = person_characteristics(
            person, event_date, person_metadata, 'pipeline')

        expected_output = {'person_id': person.person_id}

        self.assertEqual(updated_characteristics, expected_output)
Exemple #6
0
    def test_add_person_characteristics_EmptyRaceEthnicity(self):
        person = StatePerson.new_with_defaults(
            state_code="US_XX",
            person_id=12345,
            birthdate=date(1984, 8, 31),
            gender=Gender.FEMALE,
        )

        event_date = date(2010, 9, 1)

        person_metadata = PersonMetadata()

        updated_characteristics = person_characteristics(
            person, event_date, person_metadata, "pipeline")

        expected_output = {
            "age_bucket": "25-29",
            "gender": Gender.FEMALE,
            "person_id": person.person_id,
        }

        self.assertEqual(updated_characteristics, expected_output)
Exemple #7
0
    def test_add_person_characteristics_EmptyRaceEthnicity(self):
        person = StatePerson.new_with_defaults(
            person_id=12345,
            birthdate=date(1984, 8, 31),
            gender=Gender.FEMALE,
            races=[StatePersonRace.new_with_defaults()],
            ethnicities=[StatePersonEthnicity.new_with_defaults()])

        event_date = date(2010, 9, 1)

        person_metadata = PersonMetadata()

        updated_characteristics = person_characteristics(
            person, event_date, person_metadata, 'pipeline')

        expected_output = {
            'age_bucket': '25-29',
            'gender': Gender.FEMALE,
            'person_id': person.person_id
        }

        self.assertEqual(updated_characteristics, expected_output)