예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
    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)
예제 #4
0
    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)
예제 #5
0
    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)
예제 #6
0
    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')
예제 #7
0
    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)
예제 #8
0
    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)
예제 #9
0
    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()))
예제 #10
0
    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__)