def test_int_types(self): INT_TYPES = ("Int", "Check") for fieldtype in INT_TYPES: self.assertIsInstance(cast(fieldtype, value=None), int) self.assertIsInstance(cast(fieldtype, value=1.12), int) self.assertIsInstance(cast(fieldtype, value=112), int)
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_time_types(self): self.assertIsInstance(cast("Time", value=None), timedelta) self.assertIsInstance(cast("Time", value="12:03:34"), timedelta)
def test_date_types(self): self.assertIsInstance(cast("Date", value=None), date) self.assertIsInstance(cast("Date", value="12-12-2021"), date)
def test_datetime_types(self): self.assertIsInstance(cast("Datetime", value=None), datetime) self.assertIsInstance(cast("Datetime", value="12-2-22"), datetime)
def test_float_types(self): FLOAT_TYPES = ("Currency", "Float", "Percent") for fieldtype in FLOAT_TYPES: self.assertIsInstance(cast(fieldtype, value=None), float) self.assertIsInstance(cast(fieldtype, value=1.12), float) self.assertIsInstance(cast(fieldtype, value=112), float)