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


Python AccountBroker.reclaim方法代码示例

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


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

示例1: test_reclaim

# 需要导入模块: from swift.account.backend import AccountBroker [as 别名]
# 或者: from swift.account.backend.AccountBroker import reclaim [as 别名]
 def test_reclaim(self):
     broker = AccountBroker(':memory:', account='test_account')
     broker.initialize(Timestamp('1').internal)
     broker.put_container('c', Timestamp(time()).internal, 0, 0, 0,
                          POLICIES.default.idx)
     with broker.get() as conn:
         self.assertEqual(conn.execute(
             "SELECT count(*) FROM container "
             "WHERE deleted = 0").fetchone()[0], 1)
         self.assertEqual(conn.execute(
             "SELECT count(*) FROM container "
             "WHERE deleted = 1").fetchone()[0], 0)
     broker.reclaim(Timestamp(time() - 999).internal, time())
     with broker.get() as conn:
         self.assertEqual(conn.execute(
             "SELECT count(*) FROM container "
             "WHERE deleted = 0").fetchone()[0], 1)
         self.assertEqual(conn.execute(
             "SELECT count(*) FROM container "
             "WHERE deleted = 1").fetchone()[0], 0)
     sleep(.00001)
     broker.put_container('c', 0, Timestamp(time()).internal, 0, 0,
                          POLICIES.default.idx)
     with broker.get() as conn:
         self.assertEqual(conn.execute(
             "SELECT count(*) FROM container "
             "WHERE deleted = 0").fetchone()[0], 0)
         self.assertEqual(conn.execute(
             "SELECT count(*) FROM container "
             "WHERE deleted = 1").fetchone()[0], 1)
     broker.reclaim(Timestamp(time() - 999).internal, time())
     with broker.get() as conn:
         self.assertEqual(conn.execute(
             "SELECT count(*) FROM container "
             "WHERE deleted = 0").fetchone()[0], 0)
         self.assertEqual(conn.execute(
             "SELECT count(*) FROM container "
             "WHERE deleted = 1").fetchone()[0], 1)
     sleep(.00001)
     broker.reclaim(Timestamp(time()).internal, time())
     with broker.get() as conn:
         self.assertEqual(conn.execute(
             "SELECT count(*) FROM container "
             "WHERE deleted = 0").fetchone()[0], 0)
         self.assertEqual(conn.execute(
             "SELECT count(*) FROM container "
             "WHERE deleted = 1").fetchone()[0], 0)
     # Test reclaim after deletion. Create 3 test containers
     broker.put_container('x', 0, 0, 0, 0, POLICIES.default.idx)
     broker.put_container('y', 0, 0, 0, 0, POLICIES.default.idx)
     broker.put_container('z', 0, 0, 0, 0, POLICIES.default.idx)
     broker.reclaim(Timestamp(time()).internal, time())
     # self.assertEqual(len(res), 2)
     # self.assert_(isinstance(res, tuple))
     # containers, account_name = res
     # self.assert_(containers is None)
     # self.assert_(account_name is None)
     # Now delete the account
     broker.delete_db(Timestamp(time()).internal)
     broker.reclaim(Timestamp(time()).internal, time())
开发者ID:kvite,项目名称:swift,代码行数:62,代码来源:test_backend.py


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