def test_Windows_piority_of_cv_files_as_files_and_lnk_files(self): if platform.system() != 'Windows': # This test only makes sense on Windows where .filetags can exist in same dir as .filetags.lnk return # Note: cwd = subdir3 # Let's create all missing files in all dirs: filetags.create_link(self.subdir2_file, self.subdir1_file) # create link filetags.create_link(self.subdir2b_file, self.tempdir_file) # create link # prio 1 = .filetag file in startfile directory self.assertEqual(filetags.locate_and_parse_controlled_vocabulary(self.subdir1_test_file), [self.subdir1_cv]) # prio 2 = .filetag.lnk file in startfile directory os.remove(self.subdir1_file) # removing the .filetags from the subdir1 self.assertEqual(filetags.locate_and_parse_controlled_vocabulary(self.subdir1_test_file), [self.subdir2_cv]) # prio 3 = .filetag file in tempdir os.remove(self.subdir1_file + '.lnk') # removing the .filetags link file from the subdir1 self.assertEqual(filetags.locate_and_parse_controlled_vocabulary(self.subdir1_test_file), [self.tempdir_cv]) # prio 4 = .filetag.lnk file in tempdir os.remove(self.tempdir_file) # removing the .filetags link file from the subdir1 self.assertEqual(filetags.locate_and_parse_controlled_vocabulary(self.subdir1_test_file), [self.subdir2b_cv])
def test_find_cv_as_link_in_startfile_dir_when_there_is_no_cv_as_file(self): # Note: cwd = subdir3 os.remove(self.subdir1_file) # removing the .filetags from the subdir1 filetags.create_link(self.subdir2_file, self.subdir1_file) # create link self.assertEqual(filetags.locate_and_parse_controlled_vocabulary(self.subdir1_test_file), [self.subdir2_cv])
def test_find_cv_in_cwd_as_first_fallback_when_no_startfile_is_given(self): # Note: cwd = subdir3 os.remove(self.subdir1_file) # removing the .filetags from the subdir1 os.remove(self.tempdir_file) # removing the .filetags from the tempdir filetags.create_link(self.subdir2_file, os.path.join(self.subdir3, '.filetags')) # create link self.assertEqual(filetags.locate_and_parse_controlled_vocabulary(False), [self.subdir2_cv])
def create_link_file(self, source, destination): filetags.create_link(os.path.join(self.sourcedir, source), os.path.join(self.linkdir, destination))