mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Unit test fixes
This commit is contained in:
parent
484a0693d7
commit
4593b0f412
@ -250,7 +250,7 @@ class PartAPITest(InvenTreeAPITestCase):
|
|||||||
data = {'cascade': True}
|
data = {'cascade': True}
|
||||||
response = self.client.get(url, data, format='json')
|
response = self.client.get(url, data, format='json')
|
||||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
self.assertEqual(len(response.data), 13)
|
self.assertEqual(len(response.data), Part.objects.count())
|
||||||
|
|
||||||
def test_get_parts_by_cat(self):
|
def test_get_parts_by_cat(self):
|
||||||
url = reverse('api-part-list')
|
url = reverse('api-part-list')
|
||||||
|
@ -46,7 +46,7 @@ class BomItemTest(TestCase):
|
|||||||
# TODO: Tests for multi-level BOMs
|
# TODO: Tests for multi-level BOMs
|
||||||
|
|
||||||
def test_used_in(self):
|
def test_used_in(self):
|
||||||
self.assertEqual(self.bob.used_in_count, 0)
|
self.assertEqual(self.bob.used_in_count, 1)
|
||||||
self.assertEqual(self.orphan.used_in_count, 1)
|
self.assertEqual(self.orphan.used_in_count, 1)
|
||||||
|
|
||||||
def test_self_reference(self):
|
def test_self_reference(self):
|
||||||
|
@ -104,7 +104,7 @@ class StockItemListTest(StockAPITestCase):
|
|||||||
|
|
||||||
response = self.get_stock()
|
response = self.get_stock()
|
||||||
|
|
||||||
self.assertEqual(len(response), 20)
|
self.assertEqual(len(response), 29)
|
||||||
|
|
||||||
def test_filter_by_part(self):
|
def test_filter_by_part(self):
|
||||||
"""
|
"""
|
||||||
@ -113,7 +113,7 @@ class StockItemListTest(StockAPITestCase):
|
|||||||
|
|
||||||
response = self.get_stock(part=25)
|
response = self.get_stock(part=25)
|
||||||
|
|
||||||
self.assertEqual(len(response), 8)
|
self.assertEqual(len(response), 17)
|
||||||
|
|
||||||
response = self.get_stock(part=10004)
|
response = self.get_stock(part=10004)
|
||||||
|
|
||||||
@ -136,10 +136,10 @@ class StockItemListTest(StockAPITestCase):
|
|||||||
self.assertEqual(len(response), 1)
|
self.assertEqual(len(response), 1)
|
||||||
|
|
||||||
response = self.get_stock(location=1, cascade=0)
|
response = self.get_stock(location=1, cascade=0)
|
||||||
self.assertEqual(len(response), 0)
|
self.assertEqual(len(response), 7)
|
||||||
|
|
||||||
response = self.get_stock(location=1, cascade=1)
|
response = self.get_stock(location=1, cascade=1)
|
||||||
self.assertEqual(len(response), 2)
|
self.assertEqual(len(response), 9)
|
||||||
|
|
||||||
response = self.get_stock(location=7)
|
response = self.get_stock(location=7)
|
||||||
self.assertEqual(len(response), 16)
|
self.assertEqual(len(response), 16)
|
||||||
@ -153,7 +153,7 @@ class StockItemListTest(StockAPITestCase):
|
|||||||
self.assertEqual(len(response), 1)
|
self.assertEqual(len(response), 1)
|
||||||
|
|
||||||
response = self.get_stock(depleted=0)
|
response = self.get_stock(depleted=0)
|
||||||
self.assertEqual(len(response), 19)
|
self.assertEqual(len(response), 28)
|
||||||
|
|
||||||
def test_filter_by_in_stock(self):
|
def test_filter_by_in_stock(self):
|
||||||
"""
|
"""
|
||||||
@ -161,7 +161,7 @@ class StockItemListTest(StockAPITestCase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
response = self.get_stock(in_stock=1)
|
response = self.get_stock(in_stock=1)
|
||||||
self.assertEqual(len(response), 17)
|
self.assertEqual(len(response), 26)
|
||||||
|
|
||||||
response = self.get_stock(in_stock=0)
|
response = self.get_stock(in_stock=0)
|
||||||
self.assertEqual(len(response), 3)
|
self.assertEqual(len(response), 3)
|
||||||
@ -172,7 +172,7 @@ class StockItemListTest(StockAPITestCase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
codes = {
|
codes = {
|
||||||
StockStatus.OK: 18,
|
StockStatus.OK: 27,
|
||||||
StockStatus.DESTROYED: 1,
|
StockStatus.DESTROYED: 1,
|
||||||
StockStatus.LOST: 1,
|
StockStatus.LOST: 1,
|
||||||
StockStatus.DAMAGED: 0,
|
StockStatus.DAMAGED: 0,
|
||||||
@ -205,7 +205,7 @@ class StockItemListTest(StockAPITestCase):
|
|||||||
self.assertIsNotNone(item['serial'])
|
self.assertIsNotNone(item['serial'])
|
||||||
|
|
||||||
response = self.get_stock(serialized=0)
|
response = self.get_stock(serialized=0)
|
||||||
self.assertEqual(len(response), 8)
|
self.assertEqual(len(response), 17)
|
||||||
|
|
||||||
for item in response:
|
for item in response:
|
||||||
self.assertIsNone(item['serial'])
|
self.assertIsNone(item['serial'])
|
||||||
@ -217,7 +217,7 @@ class StockItemListTest(StockAPITestCase):
|
|||||||
|
|
||||||
# First, we can assume that the 'stock expiry' feature is disabled
|
# First, we can assume that the 'stock expiry' feature is disabled
|
||||||
response = self.get_stock(expired=1)
|
response = self.get_stock(expired=1)
|
||||||
self.assertEqual(len(response), 20)
|
self.assertEqual(len(response), 29)
|
||||||
|
|
||||||
self.user.is_staff = True
|
self.user.is_staff = True
|
||||||
self.user.save()
|
self.user.save()
|
||||||
@ -232,7 +232,7 @@ class StockItemListTest(StockAPITestCase):
|
|||||||
self.assertTrue(item['expired'])
|
self.assertTrue(item['expired'])
|
||||||
|
|
||||||
response = self.get_stock(expired=0)
|
response = self.get_stock(expired=0)
|
||||||
self.assertEqual(len(response), 19)
|
self.assertEqual(len(response), 28)
|
||||||
|
|
||||||
for item in response:
|
for item in response:
|
||||||
self.assertFalse(item['expired'])
|
self.assertFalse(item['expired'])
|
||||||
@ -290,7 +290,8 @@ class StockItemListTest(StockAPITestCase):
|
|||||||
|
|
||||||
dataset = self.export_data({})
|
dataset = self.export_data({})
|
||||||
|
|
||||||
self.assertEqual(len(dataset), 20)
|
# Check that *all* stock item objects have been exported
|
||||||
|
self.assertEqual(len(dataset), StockItem.objects.count())
|
||||||
|
|
||||||
# Expected headers
|
# Expected headers
|
||||||
headers = [
|
headers = [
|
||||||
@ -308,7 +309,7 @@ class StockItemListTest(StockAPITestCase):
|
|||||||
# Now, add a filter to the results
|
# Now, add a filter to the results
|
||||||
dataset = self.export_data({'location': 1})
|
dataset = self.export_data({'location': 1})
|
||||||
|
|
||||||
self.assertEqual(len(dataset), 2)
|
self.assertEqual(len(dataset), 9)
|
||||||
|
|
||||||
dataset = self.export_data({'part': 25})
|
dataset = self.export_data({'part': 25})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user