Esempio n. 1
0
    def test_remove_upload(self):
        """
        Check if `remove_upload` function correctly removes a given
        file from the TrendMiner upload directory.

        For .zip archives, the function is expected to also delete the
        folder into which the files contained in the archive were
        extracted. In order to test it, this method creates a .zip
        file and a folder with the same contents, and checks if both
        of these are removed when calling `remove_upload` on the .zip
        archive.
        """
        with self.__create_temp_file('.txt', 1024) as temp_file:
            test_zip = self.__create_test_zip(
                self.file_prefix+'.zip', temp_file.name)
            folder = os.path.join(self.upload_dir, self.file_prefix)
            os.mkdir(folder)
            shutil.copyfile(temp_file.name, os.path.join(
                    folder, os.path.basename(temp_file.name)))
            remove_upload(test_zip)
            self.assertFalse(
                os.path.exists(os.path.join(self.upload_dir, test_zip)))
            self.assertFalse(os.path.exists(folder))
Esempio n. 2
0
 def __delete_uploaded_files(cls):
     """
     Delete files uploaded by individual tests.
     """
     for upload in cls.uploaded_files:
         remove_upload(upload)