Пример #1
0
    def test_folder_conflict(self):
        # delete a folder on one side, but change content on other side 
        # Note: currently
#         raise SkipTest
        _write_test_file("local/folder1/file1_1.txt", dt="2014-01-01 13:00:00", content="local 13:00")
        _remove_test_folder("remote/folder1")

        opts = {}
        stats = _sync_test_folders(opts)
#         pprint(stats)
        self.assertEqual(stats["files_written"], 0)
        self.assertEqual(stats["download_files_written"], 0)
        self.assertEqual(stats["upload_files_written"], 0)
        self.assertEqual(stats["files_deleted"], 0)
        self.assertEqual(stats["dirs_deleted"], 1)
        self.assertEqual(stats["conflict_files"], 0)        

        expect_local = {
            'file1.txt': {'content': 'local1', 'date': '2014-01-01 12:00:00'},
            'file2.txt': {'content': 'local2', 'date': '2014-01-01 12:00:00'},
            'file3.txt': {'content': 'local3', 'date': '2014-01-01 12:00:00'},
            'file4.txt': {'content': 'local4', 'date': '2014-01-01 12:00:00'},
            'file5.txt': {'content': 'local5', 'date': '2014-01-01 12:00:00'},
            'file6.txt': {'content': 'local6', 'date': '2014-01-01 12:00:00'},
            'file7.txt': {'content': 'local7', 'date': '2014-01-01 12:00:00'},
            'file8.txt': {'content': 'local8', 'date': '2014-01-01 12:00:00'},
#             'folder1/file1_1.txt': {'content': 'local1_1', 'date': '2014-01-01 12:00:00'},
            'folder2/file2_1.txt': {'content': 'local2_1', 'date': '2014-01-01 12:00:00'},
            'folder3/file3_1.txt': {'content': 'local3_1', 'date': '2014-01-01 12:00:00'},
            'folder4/file4_1.txt': {'content': 'local4_1', 'date': '2014-01-01 12:00:00'},
            }
        self.assertDictEqual(_get_test_folder("local"), expect_local)
        self.assertDictEqual(_get_test_folder("remote"), expect_local)
Пример #2
0
    def _do_run_suite(self, opts):
        """Modify both folders and run sync with specific options.
        
                                  Local           Remote
          file1.txt               13:00           12:00
          file2.txt                 x             12:00
          file3.txt               12:00           13:00
          file4.txt               12:00             x
          file5.txt               13:00           13:00:05     CONFLICT!
          file6.txt               13:00:05        13:00        CONFLICT!
          file7.txt                 x             13:00        CONFLICT!
          file8.txt               13:00             x          CONFLICT!
          folder1/file1_1.txt     13.00
          folder2/file2_1.txt       x             12:00        CONFLICT (folder deleted)
          folder3/file3_1.txt     12:00           13:00        CONFLICT
          folder4/file4_1.txt     12:00             x          CONFLICT (folder deleted)
          new_file1.txt           13:00             -
          new_file2.txt             -             13:00
        """
        # Change, remove, and add local only
        _write_test_file("local/file1.txt", dt="2014-01-01 13:00:00", content="local 13:00")
        _remove_test_file("local/file2.txt")
        _write_test_file("local/new_file1.txt", dt="2014-01-01 13:00:00", content="local 13:00")
        _write_test_file("local/folder1/file1_1.txt", dt="2014-01-01 13:00:00", content="local 13:00")
        _remove_test_folder("local/folder2")
        # Change, remove, and add remote only
        _write_test_file("remote/file3.txt", dt="2014-01-01 13:00:00", content="remote 13:00")
        _remove_test_file("remote/file4.txt")
        _write_test_file("remote/new_file2.txt", dt="2014-01-01 13:00:00", content="remote 13:00")
        _write_test_file("remote/folder3/file3_1.txt", dt="2014-01-01 13:00:00", content="remote 13:00")
        _remove_test_folder("remote/folder4")
        # Conflict: changed local and remote, remote is newer
        _write_test_file("local/file5.txt", dt="2014-01-01 13:00:00", content="local 13:00")
        _write_test_file("remote/file5.txt", dt="2014-01-01 13:00:05", content="remote 13:00:05")
        # Conflict: changed local and remote, local is newer
        _write_test_file("local/file6.txt", dt="2014-01-01 13:00:05", content="local 13:00:05")
        _write_test_file("remote/file6.txt", dt="2014-01-01 13:00:00", content="remote 13:00")
        # Conflict: removed local, but modified remote
        _remove_test_file("local/file7.txt")
        _write_test_file("remote/file7.txt", dt="2014-01-01 13:00:00", content="remote 13:00")
        # Conflict: removed remote, but modified local
        _write_test_file("local/file8.txt", dt="2014-01-01 13:00:00", content="local 13:00")
        _remove_test_file("remote/file8.txt")

        # Synchronize folders
#         stats = self._do_sync(opts)
        stats = _sync_test_folders(opts)
        return stats