More build tests

This commit is contained in:
Oliver Walters 2019-08-15 21:49:40 +10:00
parent bed74f273c
commit 087492faf8
2 changed files with 47 additions and 3 deletions

View File

@ -4,7 +4,7 @@ omit =
# Do not run coverage on migration files
*/migrations/*
InvenTree/manage.py
InvenTree/secret.py
InvenTree/setup.py
InvenTree/InvenTree/middleware.py
InvenTree/InvenTree/utils.py
InvenTree/InvenTree/wsgi.py

View File

@ -221,6 +221,32 @@ class TestBuildViews(TestCase):
# url = reverse('build-item-edit')
pass
def test_build_complete(self):
""" Test the build completion form """
url = reverse('build-complete', args=(1,))
# Test without confirmation
response = self.client.post(url, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertEqual(response.status_code, 200)
data = json.loads(response.content)
self.assertFalse(data['form_valid'])
# Test with confirmation, valid location
response = self.client.post(url, {'confirm': 1, 'location': 1}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertEqual(response.status_code, 200)
data = json.loads(response.content)
self.assertTrue(data['form_valid'])
# Test with confirmation, invalid location
response = self.client.post(url, {'confirm': 1, 'location': 9999}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertEqual(response.status_code, 200)
data = json.loads(response.content)
self.assertFalse(data['form_valid'])
def test_build_cancel(self):
""" Test the build cancellation form """
@ -231,7 +257,6 @@ class TestBuildViews(TestCase):
self.assertEqual(response.status_code, 200)
data = json.loads(response.content)
self.assertFalse(data['form_valid'])
b = Build.objects.get(pk=1)
@ -246,3 +271,22 @@ class TestBuildViews(TestCase):
b = Build.objects.get(pk=1)
self.assertEqual(b.status, 30) # Build status is now CANCELLED
def test_build_unallocate(self):
""" Test the build unallocation view (ajax form) """
url = reverse('build-unallocate', args=(1,))
# Test without confirmation
response = self.client.post(url, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertEqual(response.status_code, 200)
data = json.loads(response.content)
self.assertFalse(data['form_valid'])
# Test with confirmation
response = self.client.post(url, {'confirm': 1}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertEqual(response.status_code, 200)
data = json.loads(response.content)
self.assertTrue(data['form_valid'])