Skip to content

Commit

Permalink
Merge pull request #289 from Jerome-Celle/fix-waitqueue_notify_url
Browse files Browse the repository at this point in the history
Remove "," when generating retreat_notification_url
RignonNoel authored Dec 2, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents dce5fb8 + 557608d commit 332b0d4
Showing 3 changed files with 83 additions and 3 deletions.
2 changes: 1 addition & 1 deletion retirement/serializers.py
Original file line number Diff line number Diff line change
@@ -756,7 +756,7 @@ def update(self, instance, validated_data):
'retreat:retreat-notify',
args=[current_retreat.id]
)
),
)
current_retreat.notify_scheduler_waite_queue(
retrat_notification_url)

82 changes: 81 additions & 1 deletion retirement/tests/tests_viewset_Reservation.py
Original file line number Diff line number Diff line change
@@ -989,7 +989,7 @@ def test_delete_scheduler_error(self):

responses.add(
responses.POST,
settings.EXTERNAL_SCHEDULER['URL'],
settings.EXTERNAL_SCHEDULER['URL'] + '/authentication',
status=400
)

@@ -1028,6 +1028,86 @@ def test_delete_scheduler_error(self):
self.retreat2.seats = 400
self.retreat2.save()

@responses.activate
def test_delete_scheduler_working(self):
"""
Ensure emails were sent to admins if the API fails to schedule
notifications.
"""
self.client.force_authenticate(user=self.admin)

self.retreat2.seats = self.retreat2.total_reservations
self.retreat2.save()

responses.add(
responses.POST,
"http://example.com/cardpayments/v1/accounts/0123456789/"
"settlements/1/refunds",
json=SAMPLE_REFUND_RESPONSE,
status=200
)

responses.add(
responses.POST,
settings.EXTERNAL_SCHEDULER['URL'] + '/authentication',
json={'token': 'test_token'},
status=200
)

responses.add(
responses.POST,
settings.EXTERNAL_SCHEDULER['URL'] + '/tasks',
status=200
)

return_data = {
"hour":
datetime(2018, 1, 1, tzinfo=LOCAL_TIMEZONE).hour,
"minute":
(datetime(2018, 1, 1, tzinfo=LOCAL_TIMEZONE)
.minute + 5) % 60,
"url":
f'http://testserver/retreat/retreats/'
f'{self.reservation_admin.retreat.id}/notify',
"description": "Retreat wait queue notification"
}

FIXED_TIME = datetime(2018, 1, 1, tzinfo=LOCAL_TIMEZONE)

with mock.patch(
'django.utils.timezone.now', return_value=FIXED_TIME):
response = self.client.delete(
reverse(
'retreat:reservation-detail',
kwargs={'pk': self.reservation_admin.id},
),
)

self.assertEqual(
response.status_code,
status.HTTP_204_NO_CONTENT,
response.content
)

self.assertEqual(
json.loads(responses.calls[2].request.body),
return_data)

self.reservation_admin.refresh_from_db()

self.assertFalse(self.reservation_admin.is_active)
self.assertEqual(self.reservation_admin.cancelation_reason, 'U')
self.assertEqual(self.reservation_admin.cancelation_action, 'R')
self.assertEqual(self.reservation_admin.cancelation_date,
FIXED_TIME)

self.reservation_admin.is_active = True
self.reservation_admin.cancelation_date = None
self.reservation_admin.cancelation_reason = None

self.retreat2.seats = 400
self.retreat2.save()

def test_delete_not_owner(self):
"""
Ensure that a user can't delete a reservation that he doesn't own.
2 changes: 1 addition & 1 deletion retirement/views.py
Original file line number Diff line number Diff line change
@@ -422,7 +422,7 @@ def destroy(self, request, *args, **kwargs):
'retreat:retreat-notify',
args=[retreat.id]
)
),
)
retreat.notify_scheduler_waite_queue(
retreat_notification_url)

0 comments on commit 332b0d4

Please sign in to comment.