'Test the LIST command in non-passive mode.
Like L{test_passiveLIST} but in the configuration where the server
establishes the data connection to the client, rather than the other
way around.'

def test_LIST(self):

    self.client.passive = False
    def generatePort(portCmd):
        portCmd.text = ('PORT    %s' % (ftp.encodeHostPort('127.0.0.1', 9876),))
        portCmd.protocol.makeConnection(proto_helpers.StringTransport())
        self.client.lineReceived('150    File    status    okay;    about    to    open    data    connection.')
        sending = ['-rw-r--r--                0    spam                        egg                        100    Oct    10    2006    foo\r\n', '-rw-r--r--                3    spam                        egg                        100    Oct    10    2006    bar\r\n', '-rw-r--r--                4    spam                        egg                        100    Oct    10    2006    baz\r\n']
        for i in sending:
            portCmd.protocol.dataReceived(i)
        portCmd.protocol.connectionLost(failure.Failure(error.ConnectionDone('')))
    def cbList(res, fileList):
        fls = [f['filename'] for f in fileList.files]
        expected = ['foo', 'bar', 'baz']
        expected.sort()
        fls.sort()
        self.assertEqual(fls, expected)
    self.client.generatePortCommand = generatePort
    self._testLogin()
    fileList = ftp.FTPFileListProtocol()
    d = self.client.list('foo/bar', fileList).addCallback(cbList, fileList)
    self.assertEqual(self.transport.value(), ('PORT    %s\r\n' % (ftp.encodeHostPort('127.0.0.1', 9876),)).encode(self.client._encoding))
    self.transport.clear()
    self.client.lineReceived('200    PORT    OK')
    self.assertEqual(self.transport.value(), 'LIST    foo/bar\r\n')
    self.transport.clear()
    self.client.lineReceived('226    Transfer    Complete.')
    return d
