2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-20 05:46:34 +00:00

Fixed tests

- Tree classes now need extra configuration in the fixture
- Check for null pk when cleaning a tree node
This commit is contained in:
Oliver Walters
2019-09-08 19:41:54 +10:00
parent a5189b8f3f
commit dac61eafa2
6 changed files with 71 additions and 8 deletions

View File

@ -6,7 +6,11 @@
name: Electronics
description: Electronic components
parent: null
default_location: 1 # Home
default_location: 1
level: 0
tree_id: 1
lft: 1
rght: 12
- model: part.partcategory
pk: 2
@ -15,6 +19,10 @@
description: Resistors
parent: 1
default_location: null
level: 1
tree_id: 1
lft: 2
rght: 3
- model: part.partcategory
pk: 3
@ -23,6 +31,10 @@
description: Capacitors
parent: 1
default_location: null
level: 1
tree_id: 1
lft: 4
rght: 5
- model: part.partcategory
pk: 4
@ -31,6 +43,10 @@
description: Integrated Circuits
parent: 1
default_location: null
level: 1
tree_id: 1
lft: 6
rght: 11
- model: part.partcategory
pk: 5
@ -39,6 +55,10 @@
description: Microcontrollers
parent: 4
default_location: null
level: 2
tree_id: 1
lft: 7
rght: 8
- model: part.partcategory
pk: 6
@ -47,6 +67,10 @@
description: Communication interfaces
parent: 4
default_location: null
level: 2
tree_id: 1
lft: 9
rght: 10
- model: part.partcategory
pk: 7
@ -54,6 +78,10 @@
name: Mechanical
description: Mechanical componenets
default_location: null
level: 0
tree_id: 2
lft: 1
rght: 4
- model: part.partcategory
pk: 8
@ -62,3 +90,7 @@
description: Screws, bolts, etc
parent: 7
default_location: 5
level: 1
tree_id: 2
lft: 2
rght: 3

View File

@ -385,7 +385,7 @@ class Part(models.Model):
cats = self.category.get_ancestors(ascending=True, include_self=True)
for cat in cats:
if cat.defaul_location:
if cat.default_location:
return cat.default_location
# Default case - no default category found

View File

@ -48,7 +48,7 @@ class CategoryTest(TestCase):
def test_unique_childs(self):
""" Test the 'unique_children' functionality """
childs = self.electronics.getUniqueChildren()
childs = [item.pk for item in self.electronics.getUniqueChildren()]
self.assertIn(self.transceivers.id, childs)
self.assertIn(self.ic.id, childs)
@ -58,7 +58,7 @@ class CategoryTest(TestCase):
def test_unique_parents(self):
""" Test the 'unique_parents' functionality """
parents = self.transceivers.getUniqueParents()
parents = [item.pk for item in self.transceivers.getUniqueParents()]
self.assertIn(self.electronics.id, parents)
self.assertIn(self.ic.id, parents)