def test_convert_numbers_to_strings(self): input = {'num': 1.2345} actual = Caster.cast_for_sql(input) self.assertEqual(actual['num'], '1.2345')
def test_null_for_none(self): input = {'test': None} actual = Caster.cast_for_sql(input) self.assertEqual(actual['test'], 'Null')
def test_escape_quotes_in_strings(self): input = {'hello': 'bl\'ah', 'hello2': 'bl\'\'ah2'} actual = Caster.cast_for_sql(input) self.assertEqual(actual['hello'], "'bl''ah'") self.assertEqual(actual['hello2'], "'bl''''ah2'")
def test_casts_old_dates(self): input = {'date': datetime.datetime(1800, 8, 11)} actual = Caster.cast_for_sql(input) self.assertEqual(actual['date'], "Cast('1800-08-11' as datetime)")
def test_doesnt_touch_shape(self): input = {'Shape': 'blah'} actual = Caster.cast_for_sql(input) self.assertEqual(actual['Shape'], 'blah')