2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-12-14 08:19:54 +00:00

Reverse url lookup for Part model

This commit is contained in:
Oliver Walters
2019-04-25 00:59:34 +10:00
parent f9db3b680d
commit 0bc5617825
3 changed files with 23 additions and 4 deletions

View File

@@ -0,0 +1,22 @@
from django.test import TestCase
from .models import Part, PartCategory
class SimplePartTest(TestCase):
def setUp(self):
cat = PartCategory.objects.create(name='TLC', description='Top level category')
self.px = Part.objects.create(name='x', description='A part called x', buildable=True)
self.py = Part.objects.create(name='y', description='A part called y', consumable=False)
self.pz = Part.objects.create(name='z', description='A part called z', category=cat)
def test_metadata(self):
self.assertEqual(self.px.name, 'x')
self.assertEqual(self.py.get_absolute_url(), '/part/2/')
self.assertEqual(str(self.pz), 'z - A part called z')
def test_category(self):
self.assertEqual(self.px.category_path, '')
self.assertEqual(self.pz.category_path, 'TLC')