def testSkips(self): # create fresh index with exclusions expected_rules = ['a', 'b', 'c'] index = backpy.FileIndex(self.src_root, exclusion_rules=expected_rules) actual_rules = index.skips() self.assertCountEqual(expected_rules, actual_rules)
def testGetMissingDeletedFile(self): expected_missing = [self.get_one_four_five_path()] # delete a file and regenerate index self.delete_one_four_five() new_index = backpy.FileIndex(self.src_root) new_index.gen_index() actual_missing = new_index.get_missing(self.index) self.assertEqual(expected_missing, actual_missing)
def testGetDiffDeletedFile(self): expected_diff = [self.get_one_four_five_path()] # delete a file and regenerate index self.delete_one_four_five() new_index = backpy.FileIndex(self.src_root) new_index.gen_index() actual_diff = self.index.get_diff(new_index) self.assertEqual(expected_diff, actual_diff)
def testGlobalSkips(self): # create fresh index with exclusions initial_rules = ['a', 'b', 'c'] added_rules = ['d,e'] expected_rules = ['a', 'b', 'c', 'd', 'e'] backpy.add_global_skip(backpy.CONFIG_FILE, added_rules) index = backpy.FileIndex(self.src_root, exclusion_rules=initial_rules) actual_rules = index.skips() self.assertCountEqual(expected_rules, actual_rules)
def testReadIndex150(self): # create a new index and read existing (new style) index file # headings should be ignored, except files and dirs index = backpy.FileIndex(self.src_root) index.read_index(self.index_150) # check files and dirs expected_files = self.list_all_files() actual_files = index.files() if is_windows(): actual_files = self.index_to_windows_paths(actual_files) self.assertCountEqual(expected_files, actual_files)
def setUpClass(cls): super(IndexTest, cls).setUpClass() # create index cls.index = backpy.FileIndex(cls.src_root) cls.index.gen_index() # index file from backpy v1.4.7 cls.index_147 = os.path.join(backpy.TEMP_DIR, 'resources', 'index_147') # index file from backpy v1.5.0 cls.index_150 = os.path.join(backpy.TEMP_DIR, 'resources', 'index_150')
def testReadIndexNotFound(self): # create a new index and try to read non-existant index file index = backpy.FileIndex(self.src_root) index.read_index() # check files and dirs expected_files = [] actual_files = index.files() self.assertCountEqual(expected_files, actual_files) # source is always added expected_dirs = [self.src_root] actual_dirs = index.dirs() self.assertCountEqual(expected_dirs, actual_dirs)
def testReadIndex(self): # create a new index and read existing (old style) index file index = backpy.FileIndex(self.src_root) index.read_index(self.index_147) # check files and dirs expected_files = self.list_all_files() actual_files = index.files() if is_windows(): actual_files = self.index_to_windows_paths(actual_files) self.assertCountEqual(expected_files, actual_files) expected_dirs = self.list_all_dirs() actual_dirs = index.dirs() if is_windows(): actual_dirs = self.index_to_windows_paths(actual_dirs) self.assertCountEqual(expected_dirs, actual_dirs)
def testIsValidSkippedFile(self): # create fresh index with one exclusion expected_rules = ['*four*'] index = backpy.FileIndex(self.src_root, exclusion_rules=expected_rules) self.assertFalse(index.is_valid(self.get_one_four_five_path()))
def testReadIndexCheckAdb(self): # create a new index and read existing (new style) index file index = backpy.FileIndex(self.src_root) index.read_index(self.index_150) self.assertFalse(index.__adb__)