def test_convert_to_timestamps(self): source = { "date": timezone.datetime(2015, 9, 7, 17, 5, 32, tzinfo=timezone.utc), "num": 1, "child": { "date": timezone.datetime(2015, 9, 7, 17, 5, 32, tzinfo=timezone.utc), "num": 1, }, } converted = TelegramType.convert_date( source, TelegramType.datetime_to_timestamp) self.assertEqual( converted, { "date": 1441645532, "num": 1, "child": { "date": 1441645532, "num": 1, }, }, )
def test_convert_to_timestamps(self): source = { 'date': timezone.datetime( 2015, 9, 7, 17, 5, 32, tzinfo=timezone.utc), 'num': 1, 'child': { 'date': timezone.datetime( 2015, 9, 7, 17, 5, 32, tzinfo=timezone.utc), 'num': 1, } } converted = TelegramType.convert_date( source, TelegramType.datetime_to_timestamp ) self.assertEqual( converted, { 'date': 1441645532, 'num': 1, 'child': { 'date': 1441645532, 'num': 1, } } )
def test_convert_froms(self): source = { "from": "name", "num": 1, "child": { "from": "name", "num": 1, }, } converted = TelegramType.convert_froms(source) self.assertEqual( converted, { "from_user": "******", "num": 1, "child": { "from_user": "******", "num": 1, }, }, )
def test_convert_froms(self): source = { 'from': 'name', 'num': 1, 'child': { 'from': 'name', 'num': 1, } } converted = TelegramType.convert_froms(source) self.assertEqual( converted, { 'from_user': '******', 'num': 1, 'child': { 'from_user': '******', 'num': 1, } } )
def test_timestamp_to_datetime(self): timestamp = 1441645532 dt = TelegramType.timestamp_to_datetime(timestamp) self.assertEqual( dt, timezone.datetime(2015, 9, 7, 17, 5, 32, tzinfo=timezone.utc))