diff --git a/argoDatabase.py b/argoDatabase.py index 60249a8..7a030b2 100644 --- a/argoDatabase.py +++ b/argoDatabase.py @@ -103,7 +103,10 @@ def create_df_of_files(files): @staticmethod def delete_list_of_files(files): for file in files: - os.remove(file) + try: + os.remove(file) + except Exception as err: + pass def remove_duplicate_if_mixed(self, files): '''remove platforms from core that exist in mixed df''' diff --git a/test/argoDatabaseTest.py b/test/argoDatabaseTest.py index 6e2abbe..fc9709d 100644 --- a/test/argoDatabaseTest.py +++ b/test/argoDatabaseTest.py @@ -141,6 +141,23 @@ def test_dump_threshold(self): self.ad.add_locally(self.OUTPUTDIR, files) docLength = len(self.ad.documents) self.assertEqual(docLength, 0, 'documents should have been reinitialized: doc length: {}'.format(docLength)) + + def test_delete_list_of_files(self): + profiles = ['6901762_46.nc', '6901762_8.nc'] + dummyDir = 'dummyTmp' + os.mkdir('dummyTmp') + files = [] + # create files + for profile in profiles: + file = os.path.join(os.getcwd(), dummyDir, profile) + files.append(file) + cmd = 'touch ' + file + os.system(cmd) + self.assertTrue(os.path.exists(file), 'file should have been created') + # remove files + self.ad.delete_list_of_files(files) + for file in files: + self.assertFalse(os.path.exists(file), 'path should have been deleted') def test_format_param(self): return