Beispiel #1
0
    def setUp(self):
        """
        Create a filesystem for tests.
        """
        self.root = inmem.FakeDirectory()
        self.f = self.root.createFile('file.txt')

        filesystem = pathutils.FileSystem(self.root)
        self.shell = FileSystemToIFTPShellAdaptor(filesystem)
Beispiel #2
0
    def setUp(self):
        """
        Create a filesystem for tests and instantiate a FTP shell.
        """
        self.root = inmem.FakeDirectory()

        filesystem = pathutils.FileSystem(self.root)
        self.shell = FileSystemToIFTPShellAdaptor(filesystem)
Beispiel #3
0
class ReadWriteVFSTestCase(unittest.TestCase, IReadWriteTestsMixin):
    """
    Tests for L{twisted.vfs.adapters.ftp.FTPReadVFS} and
    L{twisted.vfs.adapters.ftp.FTPWriteVFS}, objects returned by the shell in
    C{openforReading} and C{openForWriting}
    """

    def setUp(self):
        """
        Create a filesystem for tests.
        """
        self.root = inmem.FakeDirectory()
        self.f = self.root.createFile('file.txt')

        filesystem = pathutils.FileSystem(self.root)
        self.shell = FileSystemToIFTPShellAdaptor(filesystem)


    def getFileReader(self, content):
        """
        Return a C{FTPReadVFS} instance via C{openForReading}.
        """
        self.f.writeChunk(0, content)
        return self.shell.openForReading(('file.txt',))


    def getFileWriter(self):
        """
        Return a C{FTPWriteVFS} instance via C{openForWriting}.
        """
        return self.shell.openForWriting(('file.txt',))


    def getFileContent(self):
        """
        Return the content of the inmem file.
        """
        return self.f.readChunk(0, -1)