|
41 | 41 | key |
42 | 42 | from ietf.nomcom.utils import get_nomcom_by_year, make_nomineeposition, \ |
43 | 43 | get_hash_nominee_position, is_eligible, list_eligible, \ |
44 | | - get_eligibility_date, suggest_affiliation |
| 44 | + get_eligibility_date, suggest_affiliation, \ |
| 45 | + decorate_volunteers_with_qualifications |
45 | 46 | from ietf.person.factories import PersonFactory, EmailFactory |
46 | 47 | from ietf.person.models import Email, Person |
47 | 48 | from ietf.stats.models import MeetingRegistration |
@@ -2529,3 +2530,49 @@ def test_suggest_affiliation(self): |
2529 | 2530 | self.assertEqual(suggest_affiliation(person), 'volunteer_affil') |
2530 | 2531 | MeetingRegistrationFactory(person=person, affiliation='meeting_affil') |
2531 | 2532 | self.assertEqual(suggest_affiliation(person), 'meeting_affil') |
| 2533 | + |
| 2534 | +class VolunteerDecoratorUnitTests(TestCase): |
| 2535 | + def test_decorate_volunteers_with_qualifications(self): |
| 2536 | + nomcom = NomComFactory(group__acronym='nomcom2021', populate_personnel=False, first_call_for_volunteers=datetime.date(2021,5,15)) |
| 2537 | + elig_date = get_eligibility_date(nomcom) |
| 2538 | + Role.objects.filter(name_id__in=('chair','secr')).delete() |
| 2539 | + |
| 2540 | + meeting_person = PersonFactory() |
| 2541 | + meetings = [MeetingFactory(number=number, date=date, type_id='ietf') for number,date in [ |
| 2542 | + ('110', datetime.date(2021, 3, 6)), |
| 2543 | + ('109', datetime.date(2020, 11, 14)), |
| 2544 | + ('108', datetime.date(2020, 7, 25)), |
| 2545 | + ('107', datetime.date(2020, 3, 21)), |
| 2546 | + ('106', datetime.date(2019, 11, 16)), |
| 2547 | + ]] |
| 2548 | + for m in meetings: |
| 2549 | + MeetingRegistrationFactory(meeting=m,person=meeting_person) |
| 2550 | + nomcom.volunteer_set.create(person=meeting_person) |
| 2551 | + |
| 2552 | + office_person = PersonFactory() |
| 2553 | + RoleHistoryFactory( |
| 2554 | + name_id='chair', |
| 2555 | + group__time= elig_date - datetime.timedelta(days=365), |
| 2556 | + group__group__state_id='conclude', |
| 2557 | + person=office_person, |
| 2558 | + ) |
| 2559 | + nomcom.volunteer_set.create(person=office_person) |
| 2560 | + |
| 2561 | + author_person = PersonFactory() |
| 2562 | + for i in range(2): |
| 2563 | + da = WgDocumentAuthorFactory(person=author_person) |
| 2564 | + DocEventFactory(type='published_rfc',doc=da.document,time=datetime.date(elig_date.year-3,elig_date.month,elig_date.day)) |
| 2565 | + nomcom.volunteer_set.create(person=author_person) |
| 2566 | + |
| 2567 | + volunteers = nomcom.volunteer_set.all() |
| 2568 | + decorate_volunteers_with_qualifications(volunteers,nomcom=nomcom) |
| 2569 | + |
| 2570 | + self.assertEqual(len(volunteers), 3) |
| 2571 | + for v in volunteers: |
| 2572 | + if v.person == meeting_person: |
| 2573 | + self.assertEqual(v.qualifications,'path_1') |
| 2574 | + if v.person == office_person: |
| 2575 | + self.assertEqual(v.qualifications,'path_2') |
| 2576 | + if v.person == author_person: |
| 2577 | + self.assertEqual(v.qualifications,'path_3') |
| 2578 | + |
0 commit comments