mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Moar unit testing plz
This commit is contained in:
parent
623a0844d3
commit
e94592e42d
@ -1,12 +1,18 @@
|
||||
|
||||
import os
|
||||
|
||||
from django.test import TestCase
|
||||
import django.core.exceptions as django_exceptions
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
from .validators import validate_overage, validate_part_name
|
||||
from . import helpers
|
||||
from .settings import STATIC_ROOT
|
||||
|
||||
from mptt.exceptions import InvalidMove
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
from stock.models import StockLocation
|
||||
|
||||
|
||||
@ -48,6 +54,13 @@ class ValidatorTest(TestCase):
|
||||
class TestHelpers(TestCase):
|
||||
""" Tests for InvenTree helper functions """
|
||||
|
||||
def test_is_image(self):
|
||||
img = os.path.abspath(os.path.join(STATIC_ROOT, 'img/blank_image.png'))
|
||||
self.assertTrue(helpers.TestIfImage(img))
|
||||
|
||||
css = os.path.abspath(os.path.join(STATIC_ROOT, 'css/inventree.css'))
|
||||
self.assertFalse(helpers.TestIfImage(css))
|
||||
|
||||
def test_image_url(self):
|
||||
""" Test if a filename looks like an image """
|
||||
|
||||
@ -90,6 +103,11 @@ class TestHelpers(TestCase):
|
||||
|
||||
self.assertEqual(helpers.getMediaUrl('xx/yy.png'), '/media/xx/yy.png')
|
||||
|
||||
def testDecimal2String(self):
|
||||
|
||||
self.assertEqual(helpers.decimal2string(Decimal('1.2345000')), '1.2345')
|
||||
self.assertEqual(helpers.decimal2string('test'), 'test')
|
||||
|
||||
|
||||
class TestQuoteWrap(TestCase):
|
||||
""" Tests for string wrapping """
|
||||
|
2
Makefile
2
Makefile
@ -56,7 +56,7 @@ test:
|
||||
# Run code coverage
|
||||
coverage:
|
||||
cd InvenTree && python3 manage.py check
|
||||
coverage run InvenTree/manage.py test build common company order part stock InvenTree
|
||||
cd InvenTree && coverage run manage.py test build common company order part stock InvenTree
|
||||
coverage html
|
||||
|
||||
# Install packages required to generate code docs
|
||||
|
Loading…
Reference in New Issue
Block a user