Skip to content

Commit

Permalink
Add reservation unit name ordering to rejected occurrences
Browse files Browse the repository at this point in the history
  • Loading branch information
matti-lamppu committed Aug 21, 2024
1 parent 8e8e10c commit c042c59
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/graphql/types/rejected_occurrence/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Meta:
),
"applicant",
("recurring_reservation__reservation_unit__pk", "reservation_unit_pk"),
("recurring_reservation__reservation_unit__name", "reservation_unit_name"),
("recurring_reservation__reservation_unit__unit__pk", "unit_pk"),
]

Expand Down
27 changes: 27 additions & 0 deletions tests/test_graphql_api/test_rejected_occurrence/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,33 @@ def test_rejected_recurrence__order__by_reservation_unit_pk(graphql):
assert response.node(2) == {"pk": occurrence_1.pk}


def test_rejected_recurrence__order__by_reservation_unit_name(graphql):
occurrence_1 = RejectedOccurrenceFactory.create(recurring_reservation__reservation_unit__name="A")
occurrence_2 = RejectedOccurrenceFactory.create(recurring_reservation__reservation_unit__name="C")
occurrence_3 = RejectedOccurrenceFactory.create(recurring_reservation__reservation_unit__name="B")

graphql.login_with_superuser()
query = rejected_occurrence_query(order_by="reservationUnitNameAsc")
response = graphql(query)

assert response.has_errors is False

assert len(response.edges) == 3
assert response.node(0) == {"pk": occurrence_1.pk}
assert response.node(1) == {"pk": occurrence_3.pk}
assert response.node(2) == {"pk": occurrence_2.pk}

query = rejected_occurrence_query(order_by="reservationUnitNameDesc")
response = graphql(query)

assert response.has_errors is False

assert len(response.edges) == 3
assert response.node(0) == {"pk": occurrence_2.pk}
assert response.node(1) == {"pk": occurrence_3.pk}
assert response.node(2) == {"pk": occurrence_1.pk}


def test_rejected_recurrence__order__by_unit_pk(graphql):
occurrence_1 = RejectedOccurrenceFactory.create()
occurrence_2 = RejectedOccurrenceFactory.create()
Expand Down

0 comments on commit c042c59

Please sign in to comment.