Exemplo n.º 1
0
 def test_illegal_cases(self):
     if IS_27_OR_LATER:
         with self.assertRaises(NotImplementedError):
             b2_folder = FakeFolder('b2', [])
             list(make_folder_sync_actions(b2_folder, b2_folder, 1))
         with self.assertRaises(NotImplementedError):
             local_folder = FakeFolder('local', [])
             list(make_folder_sync_actions(local_folder, local_folder, 1))
Exemplo n.º 2
0
 def test_illegal_cases(self):
     if IS_27_OR_LATER:
         with self.assertRaises(NotImplementedError):
             b2_folder = FakeFolder('b2', [])
             list(make_folder_sync_actions(b2_folder, b2_folder, 1))
         with self.assertRaises(NotImplementedError):
             local_folder = FakeFolder('local', [])
             list(make_folder_sync_actions(local_folder, local_folder, 1))
Exemplo n.º 3
0
    def test_b2_to_local(self):
        file_a1 = File(
            "a.txt",
            [FileVersion("id_a_100", 100, "upload")])  # only in source
        file_a2 = File(
            "c.txt",
            [FileVersion("id_c_200", 200, "upload")])  # mod time matches
        file_a3 = File(
            "d.txt", [FileVersion("id_d_100", 100, "upload")])  # newer in dest
        file_a4 = File(
            "e.txt",
            [FileVersion("id_e_300", 300, "upload")])  # newer in source

        file_b1 = File(
            "b.txt",
            [FileVersion("/dir/b.txt", 200, "upload")])  # only in dest
        file_b2 = File(
            "c.txt",
            [FileVersion("/dir/c.txt", 200, "upload")])  # mod time matches
        file_b3 = File(
            "d.txt",
            [FileVersion("/dir/d.txt", 200, "upload")])  # newer in dest
        file_b4 = File(
            "e.txt",
            [FileVersion("/dir/e.txt", 200, "upload")])  # newer in source

        folder_a = FakeFolder('b2', [file_a1, file_a2, file_a3, file_a4])
        folder_b = FakeFolder('local', [file_b1, file_b2, file_b3, file_b4])

        actions = list(make_folder_sync_actions(folder_a, folder_b, 1))
        self.assertEqual([
            "b2_download(a.txt, id_a_100)", "local_delete(/dir/b.txt)",
            "b2_download(e.txt, id_e_300)"
        ], list(map(str, actions)))
Exemplo n.º 4
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
Exemplo n.º 5
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
Exemplo n.º 6
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
Exemplo n.º 7
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
Exemplo n.º 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))
        self.assertEqual(expected_actions, [str(a) for a in actions])
Exemplo n.º 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))
        self.assertEqual(expected_actions, [str(a) for a in actions])
Exemplo n.º 10
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])
Exemplo n.º 11
0
    def test_b2_to_local(self):
        file_a1 = File("a.txt", [FileVersion("id_a_100", 100, "upload")])  # only in source
        file_a2 = File("c.txt", [FileVersion("id_c_200", 200, "upload")])  # mod time matches
        file_a3 = File("d.txt", [FileVersion("id_d_100", 100, "upload")])  # newer in dest
        file_a4 = File("e.txt", [FileVersion("id_e_300", 300, "upload")])  # newer in source

        file_b1 = File("b.txt", [FileVersion("/dir/b.txt", 200, "upload")])  # only in dest
        file_b2 = File("c.txt", [FileVersion("/dir/c.txt", 200, "upload")])  # mod time matches
        file_b3 = File("d.txt", [FileVersion("/dir/d.txt", 200, "upload")])  # newer in dest
        file_b4 = File("e.txt", [FileVersion("/dir/e.txt", 200, "upload")])  # newer in source

        folder_a = FakeFolder('b2', [file_a1, file_a2, file_a3, file_a4])
        folder_b = FakeFolder('local', [file_b1, file_b2, file_b3, file_b4])

        actions = list(make_folder_sync_actions(folder_a, folder_b, 1))
        self.assertEqual(
            [
                "b2_download(a.txt, id_a_100)", "local_delete(/dir/b.txt)",
                "b2_download(e.txt, id_e_300)"
            ], list(map(str, actions))
        )
Exemplo n.º 12
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])
Exemplo n.º 13
0
 def test_empty(self):
     folder_a = FakeFolder('b2', [])
     folder_b = FakeFolder('local', [])
     self.assertEqual([], list(make_folder_sync_actions(folder_a, folder_b, 1)))
Exemplo n.º 14
0
 def test_empty(self):
     folder_a = FakeFolder('b2', [])
     folder_b = FakeFolder('local', [])
     self.assertEqual([],
                      list(make_folder_sync_actions(folder_a, folder_b, 1)))