Skip to content
This repository was archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
added test that checks if files were deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
tylertucker202 committed Feb 12, 2019
1 parent ef19897 commit 0f15981
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion argoDatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'''
Expand Down
17 changes: 17 additions & 0 deletions test/argoDatabaseTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0f15981

Please sign in to comment.