Beispiel #1
0
 def setUp(self):
     zktestbase.TestBase.setUp(self)
     try:
         zookeeper.delete(self.handle, "/zk-python-createtest")
         zookeeper.delete(self.handle, "/zk-python-acreatetest")
     except:
         pass
Beispiel #2
0
    def test_sync_delete(self):
        ZOO_OPEN_ACL_UNSAFE = {"perms":0x1f, "scheme":"world", "id" :"anyone"}
        self.assertEqual(self.connected, True)
        ret = zookeeper.create(self.handle, "/zk-python-deletetest", "nodecontents", [ZOO_OPEN_ACL_UNSAFE], zookeeper.EPHEMERAL)
        self.assertEqual(ret, "/zk-python-deletetest")
        ret = zookeeper.delete(self.handle,"/zk-python-deletetest")
        self.assertEqual(ret, zookeeper.OK)
        children = zookeeper.get_children(self.handle, "/")
        self.assertEqual(False, "zk-python-deletetest" in children)

        # test exception
        self.assertRaises(zookeeper.NoNodeException,
                          zookeeper.delete,
                          self.handle,
                          "/zk-python-deletetest")
Beispiel #3
0
    def delete(self, path, version=-1):
        """Delete the node with the given path.

        The call will succeed if such a node exists, and the given version
        matches the node's `version` (if given).

        This operation, if successful, will trigger all the watches on the node
        of the given path left by `exists()` API calls, and the watches on the
        parent node left by `get_children()` API calls.

        :Parameters:
            - `path`: the path of the node to be deleted
            - `version`: the expected node version (or `None` to ignore
              version)

        :Exceptions:
            - `NoNodeException`: node to be deleted does not exist.
            - `BadVersionException`: given version does not match the node's
              version
            - `NotEmptyException`: node cannot be deleted because it has
              children
        """
        val = _zookeeper.delete(self.zk_handle, path, version)
        assert val == zookeeper.constants.OK
Beispiel #4
0
 def ensureDeleted(self,path):
     self.assertEqual(zookeeper.CONNECTED_STATE, zookeeper.state(self.handle), "Not connected!")
     try:
         self.assertEqual(zookeeper.OK, zookeeper.delete(self.handle, path))
     except zookeeper.NoNodeException:
         pass