|
| 1 | +import pytest |
| 2 | + |
| 3 | +from registrations.exports import RegistrationSignUpsExportXLSX |
| 4 | +from registrations.models import SignUp |
| 5 | +from registrations.tests.factories import SignUpContactPersonFactory, SignUpFactory |
| 6 | + |
| 7 | + |
| 8 | +@pytest.fixture |
| 9 | +def signup_registration(registration): |
| 10 | + signup_1 = SignUpFactory( |
| 11 | + registration=registration, |
| 12 | + first_name="John", |
| 13 | + last_name="Doe", |
| 14 | + phone_number="123456789", |
| 15 | + attendee_status=SignUp.AttendeeStatus.ATTENDING, |
| 16 | + ) |
| 17 | + SignUpContactPersonFactory( |
| 18 | + signup=signup_1, email="contact1@example.com", phone_number="123456789" |
| 19 | + ) |
| 20 | + |
| 21 | + signup_2 = SignUpFactory( |
| 22 | + registration=registration, |
| 23 | + first_name="Jane", |
| 24 | + last_name="Smith", |
| 25 | + phone_number="987654321", |
| 26 | + attendee_status=SignUp.AttendeeStatus.ATTENDING, |
| 27 | + ) |
| 28 | + SignUpContactPersonFactory( |
| 29 | + signup=signup_2, email="contact2@example.com", phone_number="987654321" |
| 30 | + ) |
| 31 | + |
| 32 | + signup_3 = SignUpFactory( |
| 33 | + registration=registration, |
| 34 | + first_name="Wait", |
| 35 | + last_name="Listed", |
| 36 | + phone_number="3254454", |
| 37 | + attendee_status=SignUp.AttendeeStatus.WAITING_LIST, |
| 38 | + ) |
| 39 | + SignUpContactPersonFactory( |
| 40 | + signup=signup_3, email="contact2@example.com", phone_number="45645637" |
| 41 | + ) |
| 42 | + |
| 43 | + return registration |
| 44 | + |
| 45 | + |
| 46 | +@pytest.mark.django_db |
| 47 | +def test_signup_order(signup_registration): |
| 48 | + registration = signup_registration |
| 49 | + exporter = RegistrationSignUpsExportXLSX(registration) |
| 50 | + table_data = exporter._get_signups_table_data() |
| 51 | + |
| 52 | + assert table_data[0][0] == "Doe John" |
| 53 | + assert table_data[1][0] == "Smith Jane" |
| 54 | + assert table_data[2][0] == "Listed Wait" |
| 55 | + |
| 56 | + |
| 57 | +@pytest.mark.django_db |
| 58 | +def test_attendee_name_format(signup_registration): |
| 59 | + registration = signup_registration |
| 60 | + exporter = RegistrationSignUpsExportXLSX(registration) |
| 61 | + table_data = exporter._get_signups_table_data() |
| 62 | + |
| 63 | + assert table_data[0][0] == "Doe John" |
0 commit comments