示例#1
0
    def test_determine_prioritized_race_or_ethnicity_no_races(self):
        person = StatePerson.new_with_defaults(state_code='US_XX',
                                               person_id=12345,
                                               birthdate=date(1984, 8, 31),
                                               gender=Gender.FEMALE)

        person.races = []

        prioritized_race_ethnicity = determine_prioritized_race_or_ethnicity(
            person, self.state_race_ethnicity_population_counts)

        self.assertIsNone(prioritized_race_ethnicity)
示例#2
0
    def test_determine_prioritized_race_or_ethnicity_external_unknown(self):
        person = StatePerson.new_with_defaults(state_code='US_XX',
                                               person_id=12345,
                                               birthdate=date(1984, 8, 31),
                                               gender=Gender.FEMALE)

        race_unsupported = StatePersonRace.new_with_defaults(
            state_code='US_XX', race=Race.EXTERNAL_UNKNOWN)

        person.races = [race_unsupported]

        prioritized_race_ethnicity = determine_prioritized_race_or_ethnicity(
            person, self.state_race_ethnicity_population_counts)

        self.assertIsNone(prioritized_race_ethnicity)
示例#3
0
    def test_determine_prioritized_race_or_ethnicity_unsupported_race(self):
        person = StatePerson.new_with_defaults(state_code='US_XX',
                                               person_id=12345,
                                               birthdate=date(1984, 8, 31),
                                               gender=Gender.FEMALE)

        # We want to raise an error if a person has a race or ethnicity that isn't in the state prioritization
        race_unsupported = StatePersonRace.new_with_defaults(
            state_code='US_XX', race=Race.NATIVE_HAWAIIAN_PACIFIC_ISLANDER)

        person.races = [race_unsupported]

        with pytest.raises(ValueError):
            _ = determine_prioritized_race_or_ethnicity(
                person, self.state_race_ethnicity_population_counts)
示例#4
0
    def test_determine_prioritized_race_or_ethnicity_unsupported_state(self):
        person = StatePerson.new_with_defaults(state_code='US_NOT_SUPPORTED',
                                               person_id=12345,
                                               birthdate=date(1984, 8, 31),
                                               gender=Gender.FEMALE)

        race_white = StatePersonRace.new_with_defaults(
            state_code='US_NOT_SUPPORTED', race=Race.WHITE)
        race_black = StatePersonRace.new_with_defaults(
            state_code='US_NOT_SUPPORTED', race=Race.BLACK)

        person.races = [race_white, race_black]

        with pytest.raises(ValueError):
            _ = determine_prioritized_race_or_ethnicity(
                person, self.state_race_ethnicity_population_counts)
示例#5
0
    def test_determine_prioritized_race_or_ethnicity_ethnicity(self):
        person = StatePerson.new_with_defaults(state_code='US_XX',
                                               person_id=12345,
                                               birthdate=date(1984, 8, 31),
                                               gender=Gender.FEMALE)

        ethnicity = StatePersonEthnicity.new_with_defaults(
            state_code='US_XX', ethnicity=Ethnicity.HISPANIC)

        person.ethnicities = [ethnicity]

        prioritized_race_ethnicity = determine_prioritized_race_or_ethnicity(
            person, self.state_race_ethnicity_population_counts)

        expected_output = Ethnicity.HISPANIC.value

        self.assertEqual(expected_output, prioritized_race_ethnicity)
示例#6
0
    def test_determine_prioritized_race_or_ethnicity_race(self):
        person = StatePerson.new_with_defaults(state_code='US_XX',
                                               person_id=12345,
                                               birthdate=date(1984, 8, 31),
                                               gender=Gender.FEMALE)

        race_white = StatePersonRace.new_with_defaults(state_code='US_XX',
                                                       race=Race.WHITE)
        race_black = StatePersonRace.new_with_defaults(state_code='US_XX',
                                                       race=Race.BLACK)

        person.races = [race_white, race_black]

        prioritized_race_ethnicity = determine_prioritized_race_or_ethnicity(
            person, self.state_race_ethnicity_population_counts)

        expected_output = Race.BLACK.value

        self.assertEqual(expected_output, prioritized_race_ethnicity)