Пример #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,
        )
        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_illegal_local_to_local(self):
     local_folder = FakeFolder('local', [])
     try:
         list(
             make_folder_sync_actions(local_folder, local_folder,
                                      FakeArgs(), 0, self.reporter))
         self.fail('should have raised NotImplementedError')
     except NotImplementedError:
         pass
Пример #3
0
 def test_illegal_b2_to_b2(self):
     b2_folder = FakeFolder('b2', [])
     try:
         list(
             make_folder_sync_actions(b2_folder, b2_folder, FakeArgs(), 0,
                                      self.reporter))
         self.fail('should have raised NotImplementedError')
     except NotImplementedError:
         pass
Пример #4
0
    def test_file_exclusions(self):
        file_a = local_file('a.txt', [100])
        file_b = local_file('b.txt', [100])
        file_c = local_file('c.txt', [100])

        local_folder = FakeFolder('local', [file_a, file_b, file_c])
        b2_folder = FakeFolder('b2', [])

        expected_actions = [
            'b2_upload(/dir/a.txt, folder/a.txt, 100)',
            'b2_upload(/dir/c.txt, folder/c.txt, 100)'
        ]

        actions = list(
            make_folder_sync_actions(local_folder, b2_folder,
                                     FakeArgs(excludeRegex=["b.txt"]), TODAY,
                                     self.reporter))
        self.assertEqual(expected_actions, [str(a) for a in actions])
Пример #5
0
    def test_file_exclusions(self):
        file_a = local_file('a.txt', [100])
        file_b = local_file('b.txt', [100])
        file_c = local_file('c.txt', [100])

        local_folder = FakeFolder('local', [file_a, file_b, file_c])
        b2_folder = FakeFolder('b2', [])

        expected_actions = [
            'b2_upload(/dir/a.txt, folder/a.txt, 100)', 'b2_upload(/dir/c.txt, folder/c.txt, 100)'
        ]

        actions = list(
            make_folder_sync_actions(
                local_folder, b2_folder, FakeArgs(excludeRegex=["b.txt"]), TODAY, self.reporter
            )
        )
        self.assertEqual(expected_actions, [str(a) for a in actions])
Пример #6
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])

        # 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_bi, file_z])
        b2_folder = FakeFolder('b2', [file_bi, file_c, file_z])

        actions = list(
            make_folder_sync_actions(local_folder, b2_folder, fakeargs, TODAY,
                                     self.reporter))
        self.assertEqual(expected_actions, [str(a) for a in actions])
Пример #7
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])

        # 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_bi, file_z])
        b2_folder = FakeFolder('b2', [file_bi, file_c, file_z])

        actions = list(
            make_folder_sync_actions(local_folder, b2_folder, fakeargs, TODAY, self.reporter)
        )
        self.assertEqual(expected_actions, [str(a) for a in actions])
Пример #8
0
    def _check_one_file(self, src_type, src_file, dst_type, dst_file, args, expected_actions):
        """
        Checks the actions generated for one file.  The file may or may not
        exist at the source, and may or may not exist at the destination.
        Passing in None means that the file does not exist.

        The source and destination files may have multiple versions.
        """
        src_folder = FakeFolder(src_type, [src_file] if src_file else [])
        dst_folder = FakeFolder(dst_type, [dst_file] if dst_file else [])
        actions = list(make_folder_sync_actions(src_folder, dst_folder, args, TODAY, self.reporter))
        action_strs = [str(a) for a in actions]
        if expected_actions != action_strs:
            print('Expected:')
            for a in expected_actions:
                print('   ', a)
            print('Actual:')
            for a in action_strs:
                print('   ', a)
        self.assertEqual(expected_actions, [str(a) for a in actions])
Пример #9
0
    def _check_one_file(self, src_type, src_file, dst_type, dst_file, args, expected_actions):
        """
        Checks the actions generated for one file.  The file may or may not
        exist at the source, and may or may not exist at the destination.
        Passing in None means that the file does not exist.

        The source and destination files may have multiple versions.
        """
        src_folder = FakeFolder(src_type, [src_file] if src_file else [])
        dst_folder = FakeFolder(dst_type, [dst_file] if dst_file else [])
        actions = list(make_folder_sync_actions(src_folder, dst_folder, args, TODAY, self.reporter))
        action_strs = [str(a) for a in actions]
        if expected_actions != action_strs:
            print('Expected:')
            for a in expected_actions:
                print('   ', a)
            print('Actual:')
            for a in action_strs:
                print('   ', a)
        self.assertEqual(expected_actions, [str(a) for a in actions])
Пример #10
0
 def test_illegal_local_to_local(self):
     local_folder = FakeFolder('local', [])
     with self.assertRaises(NotImplementedError):
         list(
             make_folder_sync_actions(local_folder, local_folder,
                                      FakeArgs(), 0, self.reporter))
Пример #11
0
 def test_illegal_b2_to_b2(self):
     b2_folder = FakeFolder('b2', [])
     with self.assertRaises(NotImplementedError):
         list(
             make_folder_sync_actions(b2_folder, b2_folder, FakeArgs(), 0,
                                      self.reporter))
Пример #12
0
 def test_illegal_local_to_local(self):
     local_folder = FakeFolder('local', [])
     with self.assertRaises(NotImplementedError):
         list(make_folder_sync_actions(local_folder, local_folder, FakeArgs(), 0, self.reporter))
Пример #13
0
 def test_illegal_b2_to_b2(self):
     b2_folder = FakeFolder('b2', [])
     with self.assertRaises(NotImplementedError):
         list(make_folder_sync_actions(b2_folder, b2_folder, FakeArgs(), 0, self.reporter))