Beispiel #1
0
 def test_sync_three_backup_folders(self, mock_subprocess):
     backup_folder = BackupFolder(Path("/foo"), "blub")
     backup_folder.get_relative_repo_paths = MagicMock(return_value=[])
     rsync = RSync(Path("/foo"),
                   [backup_folder, backup_folder, backup_folder])
     rsync.sync(Target("/tmp"), False)
     self.assertEqual(3, mock_subprocess.check_call.call_count)
Beispiel #2
0
    def test_get_relative_repo_paths_with_no_repos_should_be_empty(self):
        backup_folder = BackupFolder(Path("/home/user"), "test")
        backup_folder.find_repos_in_path()

        repos = backup_folder.get_relative_repo_paths()

        self.assertFalse(repos)
Beispiel #3
0
    def test_get_relative_repo_paths_with_one_repo_should_be_only_repo_folder_name(
        self, ):
        self.create_git_repo_in_path(Path("/home/user/test/repo"))
        backup_folder = BackupFolder(Path("/home/user"), "test")
        backup_folder.find_repos_in_path()

        repos = backup_folder.get_relative_repo_paths()

        self.assertListEqual([Path("repo")], repos)
Beispiel #4
0
 def test_sync_no_excludes(self, mock_subprocess):
     backup_folder = BackupFolder(Path("/foo"), "blub")
     backup_folder.get_relative_repo_paths = MagicMock(return_value=[])
     rsync = RSync(Path("/foo"), [backup_folder])
     rsync.sync(Target("/tmp"), False)
     mock_subprocess.check_call.assert_called_with(
         "rsync {} {} {}".format(RSync.get_options(False, []),
                                 backup_folder.path, "/tmp"),
         cwd=Path("/foo"),
         shell=True,
     )
Beispiel #5
0
    def test_find_repos_in_path_with_one_repo_in_and_one_out_of_path_should_be_one_repo(
        self, ):
        self.create_git_repo_in_path(Path("/home/user/test/repo_in"))
        self.create_git_repo_in_path(Path("/home/user/repo_out"))
        backup_folder = BackupFolder(Path("/home/user"), "test")

        backup_folder.find_repos_in_path()

        self.assertEqual(Path("/home/user/test/repo_in"),
                         backup_folder.repos[0].path)
        self.assertTrue(backup_folder.has_repos)
Beispiel #6
0
 def parse_backup_folder(self) -> List[BackupFolder]:
     backup_folders = self.__content["backupFolder"]
     return [
         BackupFolder(self.parse_home(), element["path"])
         for element in backup_folders
     ]
Beispiel #7
0
 def test_find_repos_in_path_with_no_repos_should_be_empty(self):
     backup_folder = BackupFolder(Path("/home/user"), "test")
     backup_folder.find_repos_in_path()
     self.assertFalse(backup_folder.has_repos)
     self.assertFalse(backup_folder.repos)
Beispiel #8
0
 def test_constructor(self):
     backup_folder = BackupFolder(Path("/home/user"), "test")
     self.assertEqual(Path("/home/user/test"), backup_folder.path)
     self.assertFalse(backup_folder.repos)
     self.assertFalse(backup_folder.has_repos)