mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Unit testing for Order app API
This commit is contained in:
parent
57da521833
commit
eeeb04c9f4
44
InvenTree/order/test_api.py
Normal file
44
InvenTree/order/test_api.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
"""
|
||||||
|
Tests for the Order API
|
||||||
|
"""
|
||||||
|
|
||||||
|
from rest_framework.test import APITestCase
|
||||||
|
from rest_framework import status
|
||||||
|
|
||||||
|
from django.urls import reverse
|
||||||
|
from django.contrib.auth import get_user_model
|
||||||
|
|
||||||
|
|
||||||
|
class OrderTest(APITestCase):
|
||||||
|
|
||||||
|
fixtures = [
|
||||||
|
'category',
|
||||||
|
'part',
|
||||||
|
'company',
|
||||||
|
'location',
|
||||||
|
'supplier_part',
|
||||||
|
'stock',
|
||||||
|
]
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
|
||||||
|
# Create a user for auth
|
||||||
|
User = get_user_model()
|
||||||
|
User.objects.create_user('testuser', 'test@testing.com', 'password')
|
||||||
|
self.client.login(username='testuser', password='password')
|
||||||
|
|
||||||
|
def doGet(self, url, options=''):
|
||||||
|
|
||||||
|
return self.client.get(url + "?" + options, format='json')
|
||||||
|
|
||||||
|
def test_po_list(self,):
|
||||||
|
|
||||||
|
url = reverse('api-po-list')
|
||||||
|
|
||||||
|
# List all order items
|
||||||
|
response = self.doGet(url)
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
|
# Filter by stuff
|
||||||
|
response = self.doGet(url, 'status=10&part=1&supplier_part=1')
|
||||||
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
Loading…
Reference in New Issue
Block a user