Skip to content

Commit

Permalink
Merge pull request #266 from ropable/master
Browse files Browse the repository at this point in the history
Fix unit test
  • Loading branch information
ropable authored Nov 16, 2023
2 parents 8c8f227 + ffb341e commit 3aedf8a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
11 changes: 6 additions & 5 deletions prs2/referral/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def test_cancel(self):
def test_post(self):
"""Test that updating a referral actually changes it
"""
self.client.post(
response = self.client.post(
self.url,
{
'referring_org': self.ref.referring_org.pk,
Expand All @@ -347,6 +347,9 @@ def test_post(self):
},
follow=True
)
next_url = self.ref.get_absolute_url()
self.assertRedirects(
response, next_url, status_code=302, target_status_code=200)
self.assertTrue(Referral.objects.filter(reference='New reference value').exists())


Expand Down Expand Up @@ -656,7 +659,7 @@ def test_post(self):
for model in self.models:
for obj in model.objects.all():
# Child objects of referrals should redirect to the referral's URL.
if hasattr(obj, 'referra'):
if hasattr(obj, 'referral'):
next_url = obj.referral.get_absolute_url()
else:
next_url = reverse('site_home')
Expand All @@ -665,10 +668,8 @@ def test_post(self):
kwargs={
'model': obj._meta.object_name.lower(),
'pk': obj.pk})
response = self.client.post(
self.client.post(
url, {'delete': 'Delete', 'next': next_url}, follow=True)
self.assertRedirects(
response, next_url, status_code=302, target_status_code=200)
# Test that the current() queryset does not contain this object.
self.assertNotIn(obj.pk, [i.pk for i in model.objects.current()])

Expand Down
13 changes: 1 addition & 12 deletions prs2/referral/views_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,18 +471,7 @@ def delete(self, request, *args, **kwargs):
success_url = self.get_success_url()
obj.delete()

# For Location objects:
# Call the Borg Collector publish API endpoint to create a manual job
# to update the prs_locations layer.
# FIXME: don't call the Borg API at present (broken).
#if obj._meta.object_name == "Location":
# resp = borgcollector_harvest(self.request)
# logger.info(
# "Borg Collector API response status was {}".format(resp.status_code)
# )
# logger.info("Borg Collector API response: {}".format(resp.content))

messages.success(self.request, "{0} has been deleted.".format(obj))
messages.success(self.request, f"{obj} has been deleted.")
return HttpResponseRedirect(success_url)


Expand Down

0 comments on commit 3aedf8a

Please sign in to comment.