示例#1
0
    def _check_folder_sync(self, expected_actions, fakeargs):
        # only local
        file_a = local_file('a.txt', [100])
        file_b = local_file('b.txt', [100])
        file_d = local_file('d/d.txt', [100])
        file_e = local_file('e/e.incl', [100])

        # both local and remote
        file_bi = local_file('b.txt.incl', [100])
        file_z = local_file('z.incl', [100])

        # only remote
        file_c = local_file('c.txt', [100])

        local_folder = FakeFolder(
            'local', [file_a, file_b, file_d, file_e, file_bi, file_z])
        b2_folder = FakeFolder('b2', [file_bi, file_c, file_z])

        policies_manager = ScanPoliciesManager(
            exclude_dir_regexes=fakeargs.excludeDirRegex,
            exclude_file_regexes=fakeargs.excludeRegex,
            include_file_regexes=fakeargs.includeRegex,
            exclude_all_symlinks=fakeargs.excludeAllSymlinks)
        actions = list(
            make_folder_sync_actions(local_folder, b2_folder, fakeargs, TODAY,
                                     self.reporter, policies_manager))
        self.assertEqual(expected_actions, [str(a) for a in actions])
示例#2
0
 def test_exclude_directory2(self):
     expected_list = [
         six.u('.dot_file'),
         six.u('hello.'),
         six.u('hello0'),
         six.u('\u81ea\u7531'),
     ]
     polices_manager = ScanPoliciesManager(
         exclude_dir_regexes=['hello$', 'inner'], )
     self._check_file_filters_results(polices_manager, expected_list)
示例#3
0
 def test_exclude_matches_prefix(self):
     expected_list = [
         six.u('.dot_file'),
         six.u('hello.'),
         six.u('hello/b'),
         six.u('hello0'),
         six.u('inner/b.bin'),
         six.u('inner/b.txt'),
         six.u('\u81ea\u7531'),
     ]
     polices_manager = ScanPoliciesManager(exclude_file_regexes=['.*a'])
     self._check_file_filters_results(polices_manager, expected_list)
示例#4
0
 def test_exclude_include(self):
     policy = ScanPoliciesManager(exclude_file_regexes=['a', 'b'],
                                  include_file_regexes=['ab'])
     self.assertTrue(policy.should_exclude_file('alfa'))
     self.assertTrue(policy.should_exclude_file('bravo'))
     self.assertFalse(policy.should_exclude_file('abend'))
     self.assertFalse(policy.should_exclude_file('charlie'))
示例#5
0
 def test_exclude_directory_trailing_slash_does_not_match(self):
     expected_list = [
         six.u('.dot_file'),
         six.u('hello.'),
         six.u('hello0'),
         six.u('inner/a.bin'),
         six.u('inner/a.txt'),
         six.u('inner/b.bin'),
         six.u('inner/b.txt'),
         six.u('\u81ea\u7531'),
     ]
     polices_manager = ScanPoliciesManager(
         exclude_dir_regexes=['hello$', 'inner/'], )
     self._check_file_filters_results(polices_manager, expected_list)
示例#6
0
 def test_exclusions(self):
     expected_list = [
         six.u('.dot_file'),
         six.u('hello.'),
         six.u('hello/a/1'),
         six.u('hello/a/2'),
         six.u('hello/b'),
         six.u('hello0'),
         six.u('inner/a.txt'),
         six.u('inner/b.txt'),
         six.u('inner/more/a.txt'),
         six.u('\u81ea\u7531'),
     ]
     polices_manager = ScanPoliciesManager(
         exclude_file_regexes=['.*\\.bin'])
     self._check_file_filters_results(polices_manager, expected_list)
示例#7
0
 def test_exclude_all(self):
     expected_list = []
     polices_manager = ScanPoliciesManager(exclude_file_regexes=['.*'])
     self._check_file_filters_results(polices_manager, expected_list)
示例#8
0
    def test_exclude_dir(self):
        policy = ScanPoliciesManager(include_file_regexes=['.*[.]txt$'],
                                     exclude_dir_regexes=['alfa', 'bravo$'])
        self.assertTrue(policy.should_exclude_directory('alfa'))
        self.assertTrue(policy.should_exclude_directory('alfa2'))
        self.assertTrue(policy.should_exclude_directory('alfa/hello'))

        self.assertTrue(policy.should_exclude_directory('bravo'))
        self.assertFalse(policy.should_exclude_directory('bravo2'))
        self.assertFalse(policy.should_exclude_directory('bravo/hello'))

        self.assertTrue(policy.should_exclude_file('alfa/foo'))
        self.assertTrue(policy.should_exclude_file('alfa2/hello/foo'))
        self.assertTrue(policy.should_exclude_file('alfa/hello/foo.txt'))

        self.assertTrue(policy.should_exclude_file('bravo/foo'))
        self.assertFalse(policy.should_exclude_file('bravo2/hello/foo'))
        self.assertTrue(policy.should_exclude_file('bravo/hello/foo.txt'))