Ticket #1333: 1333-1.diff

File 1333-1.diff, 2.0 KB (added by adiroiban, 3 years ago)
  • twisted/test/test_ftp.py

     
    509509            return downloader.buffer
    510510        return chainDeferred.addCallback(downloadDone)
    511511
    512     def testEmptyLIST(self):
    513         # Login
     512    def test_LISTEmpty(self):
     513        """
     514        When listing empty folders, LIST returns an empty response.
     515        """
    514516        d = self._anonymousLogin()
    515517
    516518        # No files, so the file listing should be empty
     
    519521            self.assertEqual('', result)
    520522        return d.addCallback(checkEmpty)
    521523
    522     def testLISTWithBinLsFlags(self):
    523         # Make some directories
     524    def test_LISTWithBinLsFlags(self):
     525        """
     526        LIST ignores requests for folder with names like '-al' and will list
     527        the content of current folder.
     528        """
    524529        os.mkdir(os.path.join(self.directory, 'foo'))
    525530        os.mkdir(os.path.join(self.directory, 'bar'))
    526531
     
    528533        d = self._anonymousLogin()
    529534
    530535        self._download('LIST -aL', chainDeferred=d)
     536
    531537        def checkDownload(download):
    532             # We expect 2 lines because there are two files in the root.
    533             self.assertEqual(2, len(download[:-2].split('\r\n')))
     538            list_folder_names = []
     539            for line in download.splitlines():
     540                list_folder_names.append(line.split(' ')[-1])
     541            self.assertEqual(2, len(list_folder_names))
     542            self.assertTrue('foo' in list_folder_names)
     543            self.assertTrue('bar' in list_folder_names)
     544
    534545        return d.addCallback(checkDownload)
    535546
    536     def testTwoDirLIST(self):
    537         # Make some directories
     547    def test_LISTWithContent(self):
     548        """
     549        LIST returns all folder's members, each member listed on a separate
     550        line and with name and other details.
     551        """
    538552        os.mkdir(os.path.join(self.directory, 'foo'))
    539553        os.mkdir(os.path.join(self.directory, 'bar'))
    540554