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
712c9598d1
commit
f67779c816
@ -15,8 +15,6 @@ from .validators import validate_overage, validate_part_name
|
|||||||
from . import helpers
|
from . import helpers
|
||||||
from . import version
|
from . import version
|
||||||
|
|
||||||
from mptt.exceptions import InvalidMove
|
|
||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
import InvenTree.tasks
|
import InvenTree.tasks
|
||||||
@ -203,7 +201,7 @@ class TestMPTT(TestCase):
|
|||||||
loc = StockLocation.objects.get(pk=4)
|
loc = StockLocation.objects.get(pk=4)
|
||||||
loc.parent = loc
|
loc.parent = loc
|
||||||
|
|
||||||
with self.assertRaises(InvalidMove):
|
with self.assertRaises(ValidationError):
|
||||||
loc.save()
|
loc.save()
|
||||||
|
|
||||||
def test_child_as_parent(self):
|
def test_child_as_parent(self):
|
||||||
@ -214,7 +212,7 @@ class TestMPTT(TestCase):
|
|||||||
|
|
||||||
parent.parent = child
|
parent.parent = child
|
||||||
|
|
||||||
with self.assertRaises(InvalidMove):
|
with self.assertRaises(ValidationError):
|
||||||
parent.save()
|
parent.save()
|
||||||
|
|
||||||
def test_move(self):
|
def test_move(self):
|
||||||
|
@ -44,6 +44,10 @@ class CompanyTest(InvenTreeAPITestCase):
|
|||||||
self.assertEqual(len(response.data), 2)
|
self.assertEqual(len(response.data), 2)
|
||||||
|
|
||||||
def test_company_detail(self):
|
def test_company_detail(self):
|
||||||
|
"""
|
||||||
|
Tests for the Company detail endpoint
|
||||||
|
"""
|
||||||
|
|
||||||
url = reverse('api-company-detail', kwargs={'pk': 1})
|
url = reverse('api-company-detail', kwargs={'pk': 1})
|
||||||
response = self.get(url)
|
response = self.get(url)
|
||||||
|
|
||||||
@ -52,14 +56,18 @@ class CompanyTest(InvenTreeAPITestCase):
|
|||||||
# Change the name of the company
|
# Change the name of the company
|
||||||
# Note we should not have the correct permissions (yet)
|
# Note we should not have the correct permissions (yet)
|
||||||
data = response.data
|
data = response.data
|
||||||
data['name'] = 'ACMOO'
|
|
||||||
response = self.client.patch(url, data, format='json', expected_code=400)
|
response = self.client.patch(url, data, format='json', expected_code=400)
|
||||||
|
|
||||||
self.assignRole('company.change')
|
self.assignRole('company.change')
|
||||||
|
|
||||||
|
# Update the name and set the currency to a valid value
|
||||||
|
data['name'] = 'ACMOO'
|
||||||
|
data['currency'] = 'NZD'
|
||||||
|
|
||||||
response = self.client.patch(url, data, format='json', expected_code=200)
|
response = self.client.patch(url, data, format='json', expected_code=200)
|
||||||
|
|
||||||
self.assertEqual(response.data['name'], 'ACMOO')
|
self.assertEqual(response.data['name'], 'ACMOO')
|
||||||
|
self.assertEqual(response.data['currency'], 'NZD')
|
||||||
|
|
||||||
def test_company_search(self):
|
def test_company_search(self):
|
||||||
"""
|
"""
|
||||||
@ -182,6 +190,9 @@ class ManufacturerTest(InvenTreeAPITestCase):
|
|||||||
self.assertEqual(len(response.data), 2)
|
self.assertEqual(len(response.data), 2)
|
||||||
|
|
||||||
def test_manufacturer_part_detail(self):
|
def test_manufacturer_part_detail(self):
|
||||||
|
"""
|
||||||
|
Tests for the ManufacturerPart detail endpoint
|
||||||
|
"""
|
||||||
url = reverse('api-manufacturer-part-detail', kwargs={'pk': 1})
|
url = reverse('api-manufacturer-part-detail', kwargs={'pk': 1})
|
||||||
|
|
||||||
response = self.get(url)
|
response = self.get(url)
|
||||||
|
Loading…
Reference in New Issue
Block a user