mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Reverse lookup for company URL
- Added some simple tests
This commit is contained in:
parent
5098712d9c
commit
a2d4403968
@ -4,6 +4,7 @@ from __future__ import unicode_literals
|
||||
import os
|
||||
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
|
||||
|
||||
def rename_company_image(instance, filename):
|
||||
@ -56,7 +57,7 @@ class Company(models.Model):
|
||||
return "{n} - {d}".format(n=self.name, d=self.description)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return "/company/{id}/".format(id=self.id)
|
||||
return reverse('company-detail', kwargs={'pk': self.id})
|
||||
|
||||
@property
|
||||
def part_count(self):
|
||||
|
@ -1,3 +1,19 @@
|
||||
# from django.test import TestCase
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
from .models import Company
|
||||
|
||||
|
||||
class CompanySimpleTest(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
Company.objects.create(name='ABC Co.',
|
||||
description='Seller of ABC products',
|
||||
website='www.abc-sales.com',
|
||||
address='123 Sales St.',
|
||||
is_customer=False,
|
||||
is_supplier=True)
|
||||
|
||||
def test_company_model(self):
|
||||
c = Company.objects.get(pk=1)
|
||||
self.assertEqual(c.name, 'ABC Co.')
|
||||
self.assertEqual(c.get_absolute_url(), '/company/1/')
|
Loading…
Reference in New Issue
Block a user