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


Python AccountBroker.delete_db方法代码示例

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


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

示例1: test_reclaim

# 需要导入模块: from swift.account.backend import AccountBroker [as 别名]
# 或者: from swift.account.backend.AccountBroker import delete_db [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

示例2: test_is_status_deleted

# 需要导入模块: from swift.account.backend import AccountBroker [as 别名]
# 或者: from swift.account.backend.AccountBroker import delete_db [as 别名]
 def test_is_status_deleted(self):
     # Test AccountBroker.is_status_deleted
     broker1 = AccountBroker(':memory:', account='a')
     broker1.initialize(Timestamp(time()).internal)
     self.assert_(not broker1.is_status_deleted())
     broker1.delete_db(Timestamp(time()).internal)
     self.assert_(broker1.is_status_deleted())
     broker2 = AccountBroker(':memory:', account='a')
     broker2.initialize(Timestamp(time()).internal)
     # Set delete_timestamp greater than put_timestamp
     broker2.merge_timestamps(
         time(), Timestamp(time()).internal,
         Timestamp(time() + 999).internal)
     self.assert_(broker2.is_status_deleted())
开发者ID:kvite,项目名称:swift,代码行数:16,代码来源:test_backend.py

示例3: test_delete_db_status

# 需要导入模块: from swift.account.backend import AccountBroker [as 别名]
# 或者: from swift.account.backend.AccountBroker import delete_db [as 别名]
    def test_delete_db_status(self):
        ts = (Timestamp(t).internal for t in itertools.count(int(time())))
        start = ts.next()
        broker = AccountBroker(':memory:', account='a')
        broker.initialize(start)
        info = broker.get_info()
        self.assertEqual(info['put_timestamp'], Timestamp(start).internal)
        self.assert_(Timestamp(info['created_at']) >= start)
        self.assertEqual(info['delete_timestamp'], '0')
        if self.__class__ == TestAccountBrokerBeforeMetadata:
            self.assertEqual(info['status_changed_at'], '0')
        else:
            self.assertEqual(info['status_changed_at'],
                             Timestamp(start).internal)

        # delete it
        delete_timestamp = ts.next()
        broker.delete_db(delete_timestamp)
        info = broker.get_info()
        self.assertEqual(info['put_timestamp'], Timestamp(start).internal)
        self.assert_(Timestamp(info['created_at']) >= start)
        self.assertEqual(info['delete_timestamp'], delete_timestamp)
        self.assertEqual(info['status_changed_at'], delete_timestamp)
开发者ID:kvite,项目名称:swift,代码行数:25,代码来源:test_backend.py


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