'Test a failure in NLST command.
L{ftp.FTPClient.nlst} should return a Deferred which fails with
L{ftp.CommandFailed} if the server indicates the indicated path is
invalid for some reason.'

def test_failedNLST(self):

    tr = proto_helpers.StringTransport()
    def cbConnect(host, port, factory):
        self.assertEqual(host, '127.0.0.1')
        self.assertEqual(port, 12345)
        proto = factory.buildProtocol((host, port))
        proto.makeConnection(tr)
        self.client.lineReceived('150    File    status    okay;    about    to    open    data    connection.')
        proto.connectionLost(failure.Failure(error.ConnectionDone('')))
    self.client.connectFactory = cbConnect
    self._testLogin()
    lstproto = _BufferingProtocol()
    d = self.client.nlst('foo/bar', lstproto)
    self.assertFailure(d, ftp.CommandFailed)
    self.assertEqual(self.transport.value(), 'PASV\r\n')
    self.transport.clear()
    self.client.lineReceived(passivemode_msg(self.client))
    self.assertEqual(self.transport.value(), 'NLST    foo/bar\r\n')
    self.client.lineReceived('550    foo/bar:    No    such    file    or    directory')
    return d
