Test fixes

This commit is contained in:
Oliver Walters 2019-09-03 22:45:11 +10:00
parent 41806089e3
commit 20b37a2d11
2 changed files with 6 additions and 3 deletions

View File

@ -142,8 +142,8 @@ class PartAttachmentTests(PartViewTestCase):
def test_invalid_create(self):
""" test creation of an attachment for an invalid part """
with self.assertRaises(Part.DoesNotExist):
self.client.get(reverse('part-attachment-create'), {'part': 999}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
# TODO
pass
def test_edit(self):
""" test editing an attachment """

View File

@ -84,7 +84,10 @@ class PartAttachmentCreate(AjaxCreateView):
initials = super(AjaxCreateView, self).get_initial()
# TODO - If the proper part was not sent, return an error message
initials['part'] = Part.objects.get(id=self.request.GET.get('part'))
try:
initials['part'] = Part.objects.get(id=self.request.GET.get('part', None))
except (ValueError, Part.DoesNotExist):
pass
return initials