test: Add tests for str fieldstypes cast

This commit is contained in:
Gavin D'souza 2021-08-31 12:55:31 +05:30
parent be72397bca
commit 8e96d8d522

View file

@ -95,6 +95,17 @@ class TestDataManipulation(unittest.TestCase):
self.assertTrue('<a href="mailto:test@example.com">email</a>' in html)
class TestFieldCasting(unittest.TestCase):
def test_str_types(self):
STR_TYPES = (
"Data", "Text", "Small Text", "Long Text", "Text Editor", "Select", "Link", "Dynamic Link"
)
for fieldtype in STR_TYPES:
self.assertIsInstance(cast(fieldtype, value=None), str)
self.assertIsInstance(cast(fieldtype, value="12-12-2021"), str)
self.assertIsInstance(cast(fieldtype, value=""), str)
self.assertIsInstance(cast(fieldtype, value=[]), str)
self.assertIsInstance(cast(fieldtype, value=set()), str)
def test_float_types(self):
FLOAT_TYPES = ("Currency", "Float", "Percent")
for fieldtype in FLOAT_TYPES: