From f67779c816d59f21b5a41fdeecf244037b608ae6 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 30 Jun 2021 10:37:38 +1000 Subject: [PATCH] Unit test fixes --- InvenTree/InvenTree/tests.py | 6 ++---- InvenTree/company/test_api.py | 13 ++++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/InvenTree/InvenTree/tests.py b/InvenTree/InvenTree/tests.py index b7e5b98c1b..cb570d0176 100644 --- a/InvenTree/InvenTree/tests.py +++ b/InvenTree/InvenTree/tests.py @@ -15,8 +15,6 @@ from .validators import validate_overage, validate_part_name from . import helpers from . import version -from mptt.exceptions import InvalidMove - from decimal import Decimal import InvenTree.tasks @@ -203,7 +201,7 @@ class TestMPTT(TestCase): loc = StockLocation.objects.get(pk=4) loc.parent = loc - with self.assertRaises(InvalidMove): + with self.assertRaises(ValidationError): loc.save() def test_child_as_parent(self): @@ -214,7 +212,7 @@ class TestMPTT(TestCase): parent.parent = child - with self.assertRaises(InvalidMove): + with self.assertRaises(ValidationError): parent.save() def test_move(self): diff --git a/InvenTree/company/test_api.py b/InvenTree/company/test_api.py index 345f4bf1a4..6cd7ac7e3a 100644 --- a/InvenTree/company/test_api.py +++ b/InvenTree/company/test_api.py @@ -44,6 +44,10 @@ class CompanyTest(InvenTreeAPITestCase): self.assertEqual(len(response.data), 2) def test_company_detail(self): + """ + Tests for the Company detail endpoint + """ + url = reverse('api-company-detail', kwargs={'pk': 1}) response = self.get(url) @@ -52,14 +56,18 @@ class CompanyTest(InvenTreeAPITestCase): # Change the name of the company # Note we should not have the correct permissions (yet) data = response.data - data['name'] = 'ACMOO' response = self.client.patch(url, data, format='json', expected_code=400) 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) self.assertEqual(response.data['name'], 'ACMOO') + self.assertEqual(response.data['currency'], 'NZD') def test_company_search(self): """ @@ -182,6 +190,9 @@ class ManufacturerTest(InvenTreeAPITestCase): self.assertEqual(len(response.data), 2) def test_manufacturer_part_detail(self): + """ + Tests for the ManufacturerPart detail endpoint + """ url = reverse('api-manufacturer-part-detail', kwargs={'pk': 1}) response = self.get(url)