Пример #1
0
 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,
             },
         },
     )
Пример #2
0
    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,

                }
            }
        )
Пример #3
0
 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,
             },
         },
     )
Пример #4
0
    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,

                }
            }
        )
Пример #5
0
 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))