|
5 | 5 | from tests.factories import ( |
6 | 6 | AgeGroupFactory, |
7 | 7 | ApplicationEventFactory, |
| 8 | + ApplicationEventScheduleFactory, |
8 | 9 | ApplicationFactory, |
9 | 10 | CityFactory, |
10 | 11 | ReservationPurposeFactory, |
@@ -491,6 +492,39 @@ def test_application_event__filter__by_priority__multiple(graphql): |
491 | 492 | assert response.node(1) == {"pk": event_2.pk} |
492 | 493 |
|
493 | 494 |
|
| 495 | +def test_application_event__filter__schedule_priority(graphql): |
| 496 | + # given: |
| 497 | + # - There is an application event with schedules of different priorities |
| 498 | + # - A superuser is using the system |
| 499 | + schedule_high = ApplicationEventScheduleFactory.create(priority=PriorityChoice.HIGH) |
| 500 | + ApplicationEventScheduleFactory.create( |
| 501 | + application_event=schedule_high.application_event, priority=PriorityChoice.MEDIUM |
| 502 | + ) |
| 503 | + schedule_low = ApplicationEventScheduleFactory.create( |
| 504 | + application_event=schedule_high.application_event, priority=PriorityChoice.LOW |
| 505 | + ) |
| 506 | + graphql.login_user_based_on_type(UserType.SUPERUSER) |
| 507 | + |
| 508 | + # when: |
| 509 | + # - User tries to filter application event schedules with a specific priority |
| 510 | + query = events_query( |
| 511 | + fields="pk applicationEventSchedules { pk priority }", |
| 512 | + application_event_schedules__priority=[PriorityChoice.HIGH.value, PriorityChoice.LOW.value], |
| 513 | + ) |
| 514 | + response = graphql(query) |
| 515 | + |
| 516 | + # then: |
| 517 | + # - The response contains no errors |
| 518 | + # - The response contains the right application event with only the requested schedules |
| 519 | + assert response.has_errors is False, response |
| 520 | + assert len(response.edges) == 1, response |
| 521 | + assert response.node(0)["pk"] == schedule_high.application_event.pk |
| 522 | + assert response.node(0)["applicationEventSchedules"] == [ |
| 523 | + {"pk": schedule_high.pk, "priority": PriorityChoice.HIGH}, |
| 524 | + {"pk": schedule_low.pk, "priority": PriorityChoice.LOW}, |
| 525 | + ] |
| 526 | + |
| 527 | + |
494 | 528 | def test_application_event__filter__by_preferred_order(graphql): |
495 | 529 | # given: |
496 | 530 | # - There is a draft application with application events with different preferred orders |
|
0 commit comments