Coverage tests for new functions

This commit is contained in:
Oliver Walters 2020-04-07 11:50:46 +10:00
parent d06018cbbe
commit 623a0844d3
2 changed files with 19 additions and 1 deletions

View File

@ -101,7 +101,7 @@ def isNull(text):
True if the text looks like a null value
"""
return str(text).strip().lower() in ['top', 'null', 'none', 'empty', 'false', '-1']
return str(text).strip().lower() in ['top', 'null', 'none', 'empty', 'false', '-1', '']
def decimal2string(d):

View File

@ -72,6 +72,24 @@ class TestHelpers(TestCase):
self.assertFalse(helpers.str2bool(s))
self.assertFalse(helpers.str2bool(s, test=False))
def test_isnull(self):
for s in ['null', 'none', '', '-1', 'false']:
self.assertTrue(helpers.isNull(s))
for s in ['yes', 'frog', 'llama', 'true']:
self.assertFalse(helpers.isNull(s))
def testStaticUrl(self):
self.assertEqual(helpers.getStaticUrl('test.jpg'), '/static/test.jpg')
self.assertEqual(helpers.getBlankImage(), '/static/img/blank_image.png')
self.assertEqual(helpers.getBlankThumbnail(), '/static/img/blank_image.thumbnail.png')
def testMediaUrl(self):
self.assertEqual(helpers.getMediaUrl('xx/yy.png'), '/media/xx/yy.png')
class TestQuoteWrap(TestCase):
""" Tests for string wrapping """