From afcd41135856421c9ab6447d5e5ab590f63bda3f Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 8 Aug 2019 23:00:01 +1000 Subject: [PATCH] (partial) tests for attachment forms --- InvenTree/part/test_views.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/InvenTree/part/test_views.py b/InvenTree/part/test_views.py index 2c2ec4cf59..c58959aeb3 100644 --- a/InvenTree/part/test_views.py +++ b/InvenTree/part/test_views.py @@ -83,10 +83,27 @@ class PartEditTest(PartViewTestCase): self.assertIn('html_form', data) self.assertIn('"title":', data) - def test_invalid_part(self): - response = self.client.get(reverse('part-edit', args=(9999,)), HTTP_X_REQUESTED_WITH='XMLHttpRequest') - self.assertEqual(response.status_code, 404) +class PartAttachmentTests(PartViewTestCase): + + def test_valid_create(self): + """ test creation of an attachment for a valid part """ + + response = self.client.get(reverse('part-attachment-create'), {'part': 1}, HTTP_X_REQUESTED_WITH='XMLHttpRequest') + self.assertEqual(response.status_code, 200) + + def test_invalid_create(self): + """ test creation of an attachment for an invalid part """ + + with self.assertRaises(Part.DoesNotExist): + response = self.client.get(reverse('part-attachment-create'), {'part': 999}, HTTP_X_REQUESTED_WITH='XMLHttpRequest') + + def test_edit(self): + """ test editing an attachment """ + + # TODO + pass + class PartQRTest(PartViewTestCase): """ Tests for the Part QR Code AJAX view """