Beispiel #1
0
    def test_recursive(self):
        Options = collections.namedtuple('args',
                                         'recursive force command_args')
        options = Options(recursive=True, force=True,
                          command_args=['/some_path'])
        command = Rm()
        command.prepare(options)

        client = mock.Mock()
        token = Token(version=10,
                      name='/some_path/some_token',
                      owner='some_owner',
                      expirationTime=10,
                      data='some_data')
        query_response = QueryResponse(tokens=[[token]])
        client.query.return_value = query_response

        modify_response = ModifyResponse()
        client.modify.return_value = modify_response

        output = command.execute(client, None)

        query = Query(namePrefix='/some_path')
        query_request = QueryRequest(queries=[query])
        client.query.assert_called_once_with(query_request)

        modify_request = ModifyRequest(deletes=[token])
        client.modify.assert_called_once_with(modify_request)

        self.assertEqual('removed 1 token(s)\n', output)
Beispiel #2
0
    def test_recursive(self):
        Options = collections.namedtuple('args',
                                         'recursive force command_args')
        options = Options(recursive=True, force=True,
                          command_args=['/some_path'])
        command = Rm()
        command.prepare(options)

        client = mock.Mock()
        token = Token(version=10,
                      name='/some_path/some_token',
                      owner='some_owner',
                      expirationTime=10,
                      data='some_data')
        query_response = QueryResponse(tokens=[[token]])
        client.query.return_value = query_response

        modify_response = ModifyResponse()
        client.modify.return_value = modify_response

        output = command.execute(client, None)

        query = Query(namePrefix='/some_path')
        query_request = QueryRequest(queries=[query])
        client.query.assert_called_once_with(query_request)

        modify_request = ModifyRequest(deletes=[token])
        client.modify.assert_called_once_with(modify_request)

        self.assertEqual('removed 1 token(s)\n', output)
Beispiel #3
0
    def test_empty(self):
        Options = collections.namedtuple("args", "recursive force command_args")
        options = Options(recursive=False, force=True, command_args=["/some_path"])
        command = Rm()
        command.prepare(options)
        client = mock.Mock()
        response = QueryResponse()
        client.query.return_value = response

        output = command.execute(client, None)

        query = Query(namePrefix="/some_path")
        request = QueryRequest(queries=[query])
        client.query.assert_called_once_with(request)
        self.assertEqual("no tokens found\nremoved 0 token(s)\n", output)
Beispiel #4
0
    def test_empty(self):
        Options = collections.namedtuple('args',
                                         'recursive force command_args')
        options = Options(recursive=False, force=True,
                          command_args=['/some_path'])
        command = Rm()
        command.prepare(options)
        client = mock.Mock()
        response = QueryResponse()
        client.query.return_value = response

        output = command.execute(client, None)

        query = Query(namePrefix='/some_path')
        request = QueryRequest(queries=[query])
        client.query.assert_called_once_with(request)
        self.assertEqual('no tokens found\nremoved 0 token(s)\n', output)