mirror of
https://github.com/apache/superset.git
synced 2024-09-17 11:09:47 -04:00
198226a39f
* [panoramix] -> [dashed] * merge from caravel/master * Updated from airbnb * Cleaning * Rebase with upstream/master * merge from caravel/master * Updated from airbnb * Cleaning * Manual rebase * Last pending change to rebase * Convert date to datetime before serialization. Approach choosen: transform data before serialize and keep just one way to serialize * Unit test created * stupid error :( * remove uneeded code and rename test * Avoid double type checking Test updated note: isinstance(<datetime>, <date>) == True, check order changed * Increase coverage * Fix assertRaises
20 lines
744 B
Python
20 lines
744 B
Python
from datetime import datetime, date, timedelta
|
|
from caravel import utils
|
|
import unittest
|
|
|
|
|
|
class UtilsTestCase(unittest.TestCase):
|
|
def test_json_int_dttm_ser(self):
|
|
today = date.today()
|
|
now = datetime.now()
|
|
ms = utils.json_int_dttm_ser(today)
|
|
deser = (utils.EPOCH + timedelta(milliseconds=ms)).date()
|
|
assert today == deser, "Serialization error: %s is not %s" % (str(today), str(deser))
|
|
ms = utils.json_int_dttm_ser(now)
|
|
deser = (utils.EPOCH + timedelta(milliseconds=ms))
|
|
assert now == deser, "Serialization error: %s is not %s" % (str(now), str(deser))
|
|
|
|
with self.assertRaises(TypeError):
|
|
utils.json_int_dttm_ser("this is not a date")
|
|
|