本文整理汇总了Python中ikalog.utils.IkaUtils.getTime方法的典型用法代码示例。如果您正苦于以下问题:Python IkaUtils.getTime方法的具体用法?Python IkaUtils.getTime怎么用?Python IkaUtils.getTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ikalog.utils.IkaUtils
的用法示例。
在下文中一共展示了IkaUtils.getTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_time
# 需要导入模块: from ikalog.utils import IkaUtils [as 别名]
# 或者: from ikalog.utils.IkaUtils import getTime [as 别名]
def test_get_time(self):
mock_context = {'engine': {'epoch_time': None, 'msec': 5000}}
# epoch_time is None
time_before = time.time()
time_actual = IkaUtils.getTime(mock_context)
time_after = time.time()
self.assertTrue(time_before <= time_actual <= time_after)
# epoch_time is 0
mock_context['engine']['epoch_time'] = 0
expected_time = (mock_context['engine']['epoch_time'] +
mock_context['engine']['msec'] / 1000.0)
self.assertEqual(expected_time, IkaUtils.getTime(mock_context))
# epoch_time is 2015-05-28 10:00:00, msec is 1 hour
mock_context['engine']['epoch_time'] = (
time.mktime(time.strptime("20150528_100000", "%Y%m%d_%H%M%S")))
mock_context['engine']['msec'] = 60 * 60 * 1000
time_actual = IkaUtils.getTime(mock_context)
self.assertEqual("20150528_110000",
time.strftime("%Y%m%d_%H%M%S",
time.localtime(time_actual)))