mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Unit testing for part variant MPTT
This commit is contained in:
parent
0652579312
commit
2d6c531fda
@ -97,4 +97,61 @@
|
||||
tree_id: 0
|
||||
level: 0
|
||||
lft: 0
|
||||
rght: 0
|
||||
rght: 0
|
||||
|
||||
# A 'template' part
|
||||
- model: part.part
|
||||
pk: 10000
|
||||
fields:
|
||||
name: 'Chair Template'
|
||||
description: 'A chair'
|
||||
is_template: True
|
||||
category: 7
|
||||
tree_id: 1
|
||||
level: 0
|
||||
lft: 0
|
||||
rght: 0
|
||||
|
||||
- model: part.part
|
||||
pk: 10001
|
||||
fields:
|
||||
name: 'Blue Chair'
|
||||
variant_of: 10000
|
||||
category: 7
|
||||
tree_id: 1
|
||||
level: 0
|
||||
lft: 0
|
||||
rght: 0
|
||||
|
||||
- model: part.part
|
||||
pk: 10002
|
||||
fields:
|
||||
name: 'Red chair'
|
||||
variant_of: 10000
|
||||
category: 7
|
||||
tree_id: 1
|
||||
level: 0
|
||||
lft: 0
|
||||
rght: 0
|
||||
|
||||
- model: part.part
|
||||
pk: 10003
|
||||
fields:
|
||||
name: 'Green chair'
|
||||
variant_of: 10000
|
||||
category: 7
|
||||
tree_id: 1
|
||||
level: 0
|
||||
lft: 0
|
||||
rght: 0
|
||||
|
||||
- model: part.part
|
||||
pk: 10004
|
||||
fields:
|
||||
name: 'Green chair variant'
|
||||
variant_of: 10003
|
||||
category:
|
||||
tree_id: 1
|
||||
level: 0
|
||||
lft: 0
|
||||
rght: 0
|
||||
|
@ -52,6 +52,18 @@ class PartTest(TestCase):
|
||||
|
||||
self.C1 = Part.objects.get(name='C_22N_0805')
|
||||
|
||||
Part.objects.rebuild()
|
||||
|
||||
def test_tree(self):
|
||||
# Test that the part variant tree is working properly
|
||||
chair = Part.objects.get(pk=10000)
|
||||
self.assertEqual(chair.get_children().count(), 3)
|
||||
self.assertEqual(chair.get_descendant_count(), 4)
|
||||
|
||||
green = Part.objects.get(pk=10004)
|
||||
self.assertEqual(green.get_ancestors().count(), 2)
|
||||
self.assertEqual(green.get_root(), chair)
|
||||
|
||||
def test_str(self):
|
||||
p = Part.objects.get(pk=100)
|
||||
self.assertEqual(str(p), "BOB | Bob | A2 - Can we build it?")
|
||||
|
Loading…
Reference in New Issue
Block a user