Fix unit testings

This commit is contained in:
Oliver Walters 2020-03-22 20:13:38 +11:00
parent 672119fb92
commit 25caec4c53
2 changed files with 8 additions and 8 deletions

View File

@ -138,7 +138,7 @@ class PurchaseOrder(Order):
) )
def get_absolute_url(self): def get_absolute_url(self):
return reverse('purchase-order-detail', kwargs={'pk': self.id}) return reverse('po-detail', kwargs={'pk': self.id})
@transaction.atomic @transaction.atomic
def add_line_item(self, supplier_part, quantity, group=True, reference=''): def add_line_item(self, supplier_part, quantity, group=True, reference=''):

View File

@ -40,7 +40,7 @@ class OrderViewTestCase(TestCase):
class OrderListTest(OrderViewTestCase): class OrderListTest(OrderViewTestCase):
def test_order_list(self): def test_order_list(self):
response = self.client.get(reverse('purchase-order-index')) response = self.client.get(reverse('po-index'))
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
@ -50,14 +50,14 @@ class POTests(OrderViewTestCase):
def test_detail_view(self): def test_detail_view(self):
""" Retrieve PO detail view """ """ Retrieve PO detail view """
response = self.client.get(reverse('purchase-order-detail', args=(1,))) response = self.client.get(reverse('po-detail', args=(1,)))
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
keys = response.context.keys() keys = response.context.keys()
self.assertIn('OrderStatus', keys) self.assertIn('OrderStatus', keys)
def test_po_create(self): def test_po_create(self):
""" Launch forms to create new PurchaseOrder""" """ Launch forms to create new PurchaseOrder"""
url = reverse('purchase-order-create') url = reverse('po-create')
# Without a supplier ID # Without a supplier ID
response = self.client.get(url, HTTP_X_REQUESTED_WITH='XMLHttpRequest') response = self.client.get(url, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
@ -74,13 +74,13 @@ class POTests(OrderViewTestCase):
def test_po_edit(self): def test_po_edit(self):
""" Launch form to edit a PurchaseOrder """ """ Launch form to edit a PurchaseOrder """
response = self.client.get(reverse('purchase-order-edit', args=(1,)), HTTP_X_REQUESTED_WITH='XMLHttpRequest') response = self.client.get(reverse('po-edit', args=(1,)), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
def test_po_export(self): def test_po_export(self):
""" Export PurchaseOrder """ """ Export PurchaseOrder """
response = self.client.get(reverse('purchase-order-export', args=(1,)), HTTP_X_REQUESTED_WITH='XMLHttpRequest') response = self.client.get(reverse('po-export', args=(1,)), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
# Response should be streaming-content (file download) # Response should be streaming-content (file download)
self.assertIn('streaming_content', dir(response)) self.assertIn('streaming_content', dir(response))
@ -88,7 +88,7 @@ class POTests(OrderViewTestCase):
def test_po_issue(self): def test_po_issue(self):
""" Test PurchaseOrderIssue view """ """ Test PurchaseOrderIssue view """
url = reverse('purchase-order-issue', args=(1,)) url = reverse('po-issue', args=(1,))
order = PurchaseOrder.objects.get(pk=1) order = PurchaseOrder.objects.get(pk=1)
self.assertEqual(order.status, OrderStatus.PENDING) self.assertEqual(order.status, OrderStatus.PENDING)
@ -183,7 +183,7 @@ class TestPOReceive(OrderViewTestCase):
self.po = PurchaseOrder.objects.get(pk=1) self.po = PurchaseOrder.objects.get(pk=1)
self.po.status = OrderStatus.PLACED self.po.status = OrderStatus.PLACED
self.po.save() self.po.save()
self.url = reverse('purchase-order-receive', args=(1,)) self.url = reverse('po-receive', args=(1,))
def post(self, data, validate=None): def post(self, data, validate=None):