Run tests on custom validators

This commit is contained in:
Oliver Walters 2019-06-17 22:18:00 +10:00
parent b9dc4a0c2f
commit 08358f6961
3 changed files with 40 additions and 2 deletions

View File

@ -0,0 +1,38 @@
from django.test import TestCase
import django.core.exceptions as django_exceptions
from .validators import validate_overage, validate_part_name
class ValidatorTest(TestCase):
""" Simple tests for custom field validators """
def test_part_name(self):
""" Test part name validator """
validate_part_name('hello world')
with self.assertRaises(django_exceptions.ValidationError):
validate_part_name('This | name is not } valid')
def test_overage(self):
""" Test overage validator """
validate_overage("100%")
validate_overage("10")
validate_overage("45.2 %")
with self.assertRaises(django_exceptions.ValidationError):
validate_overage("-1")
with self.assertRaises(django_exceptions.ValidationError):
validate_overage("-2.04 %")
with self.assertRaises(django_exceptions.ValidationError):
validate_overage("105%")
with self.assertRaises(django_exceptions.ValidationError):
validate_overage("xxx %")
with self.assertRaises(django_exceptions.ValidationError):
validate_overage("aaaa")

View File

@ -1,3 +1,3 @@
"""
The Order module is responsible for managing Orders
"""
"""

View File

@ -32,7 +32,7 @@ test:
coverage:
python3 InvenTree/manage.py check
coverage run InvenTree/manage.py test build company part stock order
coverage run InvenTree/manage.py test build company part stock order InvenTree
coverage html
documentation: