1"""
2Unit tests for stem.util.* contents.
3"""
4
5import datetime
6import time
7import unittest
8
9from stem.util import datetime_to_unix
10
11__all__ = [
12  'conf',
13  'connection',
14  'enum',
15  'log',
16  'proc',
17  'str_tools',
18  'system',
19  'tor_tools',
20]
21
22
23class TestBaseUtil(unittest.TestCase):
24  def test_datetime_to_unix(self):
25    self.assertEqual(1344251971.0, datetime_to_unix(datetime.datetime(2012, 8, 6, 11, 19, 31)))
26    self.assertEqual(1515894416.0, datetime_to_unix(datetime.datetime(2018, 1, 14, 1, 46, 56)))
27    self.assertTrue((time.time() - datetime_to_unix(datetime.datetime.utcnow())) < 2)
28