2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 11:10:54 +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

@ -5,6 +5,10 @@
fields:
name: 'Home'
description: 'My house'
level: 0
tree_id: 1
lft: 1
rght: 6
- model: stock.stocklocation
pk: 2
@ -12,6 +16,10 @@
name: 'Bathroom'
description: 'Where I keep my bath'
parent: 1
level: 1
tree_id: 1
lft: 2
rght: 3
- model: stock.stocklocation
pk: 3
@ -19,12 +27,20 @@
name: 'Dining Room'
description: 'A table lives here'
parent: 1
level: 0
tree_id: 1
lft: 4
rght: 5
- model: stock.stocklocation
pk: 4
fields:
name: 'Office'
description: 'Place of work'
level: 0
tree_id: 2
lft: 1
rght: 8
- model: stock.stocklocation
pk: 5
@ -32,6 +48,10 @@
name: 'Drawer_1'
description: 'In my desk'
parent: 4
level: 0
tree_id: 2
lft: 2
rght: 3
- model: stock.stocklocation
pk: 6
@ -39,10 +59,18 @@
name: 'Drawer_2'
description: 'Also in my desk'
parent: 4
level: 0
tree_id: 2
lft: 4
rght: 5
- model: stock.stocklocation
pk: 7
fields:
name: 'Drawer_3'
description: 'Again, in my desk'
parent: 4
parent: 4
level: 0
tree_id: 2
lft: 6
rght: 7

View File

@ -67,15 +67,18 @@ class StockTest(TestCase):
# Move one of the drawers
self.drawer3.parent = self.home
self.drawer3.save()
self.assertNotEqual(self.drawer3.parent, self.office)
self.assertEqual(self.drawer3.pathstring, 'Home/Drawer_3')
def test_children(self):
self.assertTrue(self.office.has_children)
self.assertFalse(self.drawer2.has_children)
childs = self.office.getUniqueChildren()
childs = [item.pk for item in self.office.getUniqueChildren()]
self.assertIn(self.drawer1.id, childs)
self.assertIn(self.drawer2.id, childs)