def test_find_younger(self): found_files = find_files(path='tests/', maximum_file_age=datetime.datetime( 2015, 10, 11)) comp_files = test_files comp_files.remove('tests/subdir1/subdir2/test3.txt') comp_files.remove('tests/test1.txt') self.assertListEqual(sorted(found_files), sorted(comp_files))
def test_find_older_younger_suffix(self): found_files = find_files( path='tests/', file_suffix=".csv", minimum_file_age=datetime.datetime(2017, 10, 11), maximum_file_age=datetime.datetime(2015, 10, 9)) comp_files = ['tests/subdir1/subdir2/test4_2018_08_17.csv'] self.assertListEqual(sorted(found_files), sorted(comp_files))
def test_find_older(self): found_files = find_files(path='tests/', minimum_file_age=datetime.datetime( 2015, 10, 11)) comp_files = ['tests/subdir1/subdir2/test3.txt', 'tests/test1.txt'] self.assertListEqual(sorted(found_files), sorted(comp_files))
def test_find_all_suffix(self): found_files = sorted(find_files('tests/', file_suffix='.csv')) comp_files = sorted([x for x in test_files if ".csv" in x]) self.assertListEqual(found_files, comp_files)
def test_find_subdir(self): found_files = sorted(find_files('tests/', recursion_depth=1)) comp_files = sorted(test_files[0:10]) self.assertListEqual(found_files, comp_files)
def test_find_root(self): found_files = find_files('tests/', recursion_depth=0) comp_files = test_files[0:3] self.assertListEqual(sorted(found_files), sorted(comp_files))
def test_find_all(self): found_files = find_files('tests/') self.assertListEqual(sorted(found_files), sorted(test_files))
def test_delete_files_and_directory(self): found_files = find_files(path='tests/subdir1/subdir2/') delete_files(found_files, True) with self.assertRaises(OSError): find_files(path='tests/subdir1/subdir2/')
def test_delete_files(self): found_files = find_files(path='tests/subdir1/subdir2/') delete_files(found_files) found_files = find_files(path='tests/subdir1/subdir2/') self.assertListEqual(found_files, [])