Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
ezkat committed Dec 13, 2023
1 parent 74ede00 commit 5c7a5c3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions resources/tests/test_reservation_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ def reservation_created_notification():
body='Normal reservation created body.',
)

@pytest.fixture
def reservation_created_by_official_notification():
with translation.override('fi'): # Staff user preferred language is always fallback. (fi)
return NotificationTemplate.objects.create(
type=NotificationType.RESERVATION_CREATED_BY_OFFICIAL,
is_default_template=True,
short_message = 'Virkailija on luonut varauksen lyhyt viesti.',
subject = 'Virkailija on luonut varauksen aihe.',
body = 'Virkailija on luonut varauksen viesti.'
)

@pytest.fixture
def reservation_modified_by_official_notification():
Expand Down Expand Up @@ -3314,3 +3324,21 @@ def test_reservation_reminder_create(
response = api_client.post(list_url, data=reservation_data, HTTP_ACCEPT_LANGUAGE='en')
assert response.status_code == 201
assert ReservationReminder.objects.count() == 1


@override_settings(RESPA_MAILS_ENABLED=True)
@pytest.mark.django_db
def test_no_notification_on_reservation_type_blocked(
resource_in_unit, reservation_data,
staff_api_client, staff_user, list_url,
reservation_created_by_official_notification):
UnitAuthorization.objects.create(subject=resource_in_unit.unit,
level=UnitAuthorizationLevel.manager, authorized=staff_user)

reservation_data['resource'] = resource_in_unit.pk
reservation_data['reserver_name'] = 'Staff reservation normal'
reservation_data['type'] = Reservation.TYPE_BLOCKED

response = staff_api_client.post(list_url, data=reservation_data, format='json')
assert response.status_code == 201
assert len(mail.outbox) == 0

0 comments on commit 5c7a5c3

Please sign in to comment.