Exemplo n.º 1
0
    def age_group_conf(self):
        if self.birthdate:
            day = c.EPOCH.date() \
                if date.today() <= c.EPOCH.date() \
                else localized_now().date()

            attendee_age = get_age_from_birthday(self.birthdate, day)
            for val, age_group in c.AGE_GROUP_CONFIGS.items():
                if val != c.AGE_UNKNOWN and \
                        age_group['min_age'] <= attendee_age and \
                        attendee_age <= age_group['max_age']:
                    return age_group

        return c.AGE_GROUP_CONFIGS[int(self.age_group or c.AGE_UNKNOWN)]
Exemplo n.º 2
0
 def test_default_today(self, birthdate_delta, expected):
     birthdate = localized_now() - birthdate_delta
     assert expected == get_age_from_birthday(birthdate)
Exemplo n.º 3
0
 def test_age_calculation(self, birthdate, today, expected):
     assert expected == get_age_from_birthday(birthdate, today)
Exemplo n.º 4
0
 def test_default_today(self, birthdate_delta, expected):
     birthdate = localized_now() - birthdate_delta
     assert expected == get_age_from_birthday(birthdate)
Exemplo n.º 5
0
 def test_age_calculation(self, birthdate, today, expected):
     assert expected == get_age_from_birthday(birthdate, today)