当前位置: 首页>>代码示例>>Python>>正文


Python oslo_utils.timeutils方法代码示例

本文整理汇总了Python中oslo_utils.timeutils方法的典型用法代码示例。如果您正苦于以下问题:Python oslo_utils.timeutils方法的具体用法?Python oslo_utils.timeutils怎么用?Python oslo_utils.timeutils使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oslo_utils的用法示例。


在下文中一共展示了oslo_utils.timeutils方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: import oslo_utils [as 别名]
# 或者: from oslo_utils import timeutils [as 别名]
def setUp(self):
        super(ServicesTest, self).setUp()

        self.mock_object(db, "service_get_all", fake_service_get_all)
        self.mock_object(timeutils, "utcnow", fake_utcnow)
        self.mock_object(db, "service_get_by_args",
                         fake_service_get_by_host_binary)
        self.mock_object(db, "service_update", fake_service_update)
        self.context = context.get_admin_context()
        self.controller = services.ServiceController()
        self.controller_legacy = services.ServiceControllerLegacy()
        self.resource_name = self.controller.resource_name
        self.mock_policy_check = self.mock_object(
            policy, 'check_policy', mock.Mock(return_value=True)) 
开发者ID:openstack,项目名称:manila,代码行数:16,代码来源:test_services.py

示例2: test_share_host_update_db

# 需要导入模块: import oslo_utils [as 别名]
# 或者: from oslo_utils import timeutils [as 别名]
def test_share_host_update_db(self):
        with mock.patch.object(timeutils, 'utcnow',
                               mock.Mock(return_value='fake-now')):
            base.share_update_db(self.context, 31337, 'fake_host')
            db.share_update.assert_called_once_with(
                self.context, 31337,
                {'host': 'fake_host', 'scheduled_at': 'fake-now'}) 
开发者ID:openstack,项目名称:manila,代码行数:9,代码来源:test_base.py

示例3: test_service_is_up

# 需要导入模块: import oslo_utils [as 别名]
# 或者: from oslo_utils import timeutils [as 别名]
def test_service_is_up(self):
        fts_func = datetime.datetime.fromtimestamp
        fake_now = 1000
        down_time = 5
        self.flags(service_down_time=down_time)
        with mock.patch.object(timeutils, 'utcnow',
                               mock.Mock(return_value=fts_func(fake_now))):

            # Up (equal)
            service = {'updated_at': fts_func(fake_now - down_time),
                       'created_at': fts_func(fake_now - down_time)}
            result = utils.service_is_up(service)
            self.assertTrue(result)
            timeutils.utcnow.assert_called_once_with()

        with mock.patch.object(timeutils, 'utcnow',
                               mock.Mock(return_value=fts_func(fake_now))):
            # Up
            service = {'updated_at': fts_func(fake_now - down_time + 1),
                       'created_at': fts_func(fake_now - down_time + 1)}
            result = utils.service_is_up(service)
            self.assertTrue(result)
            timeutils.utcnow.assert_called_once_with()

        with mock.patch.object(timeutils, 'utcnow',
                               mock.Mock(return_value=fts_func(fake_now))):
            # Down
            service = {'updated_at': fts_func(fake_now - down_time - 1),
                       'created_at': fts_func(fake_now - down_time - 1)}
            result = utils.service_is_up(service)
            self.assertFalse(result)
            timeutils.utcnow.assert_called_once_with() 
开发者ID:openstack,项目名称:manila,代码行数:34,代码来源:test_utils.py

示例4: setUp

# 需要导入模块: import oslo_utils [as 别名]
# 或者: from oslo_utils import timeutils [as 别名]
def setUp(self):
        super(DBTestBase, self).setUp()
        patcher = mock.patch.object(timeutils, 'utcnow')
        self.addCleanup(patcher.stop)
        self.mock_utcnow = patcher.start()
        self.mock_utcnow.return_value = datetime.datetime(2015, 7, 2, 10, 39) 
开发者ID:openstack,项目名称:aodh,代码行数:8,代码来源:test_storage_scenarios.py

示例5: setUp

# 需要导入模块: import oslo_utils [as 别名]
# 或者: from oslo_utils import timeutils [as 别名]
def setUp(self):
        super(ShareGroupsAPITestCase, self).setUp()
        self.user_id = 'fake_user_id'
        self.project_id = 'fake_project_id'
        self.context = context.RequestContext(
            user_id=self.user_id, project_id=self.project_id, is_admin=True)
        self.scheduler_rpcapi = mock.Mock()
        self.share_rpcapi = mock.Mock()
        self.share_api = mock.Mock()
        self.api = share_group_api.API()
        self.mock_object(self.api, 'share_rpcapi', self.share_rpcapi)
        self.mock_object(self.api, 'share_api', self.share_api)
        self.mock_object(self.api, 'scheduler_rpcapi', self.scheduler_rpcapi)

        dt_utc = datetime.datetime.utcnow()
        self.mock_object(timeutils, 'utcnow', mock.Mock(return_value=dt_utc))
        self.fake_share_type = {
            'name': 'default',
            'extra_specs': {'driver_handles_share_servers': 'False'},
            'is_public': True,
            'id': 'c01990c1-448f-435a-9de6-c7c894bb6df9'
        }
        self.fake_share_type_2 = {
            'name': 'default2',
            'extra_specs': {'driver_handles_share_servers': 'False'},
            'is_public': True,
            'id': 'c01990c1-448f-435a-9de6-c7c894bb7dfd'
        }
        self.fake_share_group_type = {
            'share_types': [
                {'share_type_id': self.fake_share_type['id']},
                {'share_type_id': self.fake_share_type_2['id']},
            ]
        }
        self.mock_object(share_types, 'get_share_type',
                         mock.Mock(return_value=self.fake_share_type))
        self.mock_object(
            db_driver, 'share_group_type_get',
            mock.Mock(return_value=self.fake_share_group_type))
        self.mock_object(share_group_api.QUOTAS, 'reserve')
        self.mock_object(share_group_api.QUOTAS, 'commit')
        self.mock_object(share_group_api.QUOTAS, 'rollback') 
开发者ID:openstack,项目名称:manila,代码行数:44,代码来源:test_api.py


注:本文中的oslo_utils.timeutils方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。