'Test a failure in the STOR command.
If the server does not acknowledge successful receipt of the
uploaded file, the second Deferred returned by
L{ftp.FTPClient.storeFile} should errback with L{ftp.CommandFailed}.'

def test_failedSTOR(self):

    tr = proto_helpers.StringTransport()
    def cbStore(sender):
        self.client.lineReceived('150    File    status    okay;    about    to    open    data    connection.')
        sender.transport.write(('x' * 1000))
        sender.finish()
        sender.connectionLost(failure.Failure(error.ConnectionDone('')))
    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.connectFactory = cbConnect
    self._testLogin()
    (d1, d2) = self.client.storeFile('spam')
    d1.addCallback(cbStore)
    self.assertFailure(d2, 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(), 'STOR    spam\r\n')
    self.transport.clear()
    self.client.lineReceived('426    Transfer    aborted.        Data    connection    closed.')
    return defer.gatherResults([d1, d2])
