Exemple #1
0
def init_source_repo(init_chm_test_session):
    """Sets up and tears down a non-bare git repo.

    Yields:
        tuple: (
            source_workdir_path,
            parent_dir_path,
            commits_from_json,

    """
    parent_dir_path = init_chm_test_session

    # Create source workdir
    source_workdir_path = create_dir(
        full_path=os.path.join(parent_dir_path, SOURCE_WORKDIR),
        on_conflict="replace",
    )

    # Create and initiallize source repo
    repo = Repo.init(source_workdir_path)

    # Make the commits
    commits = make_commits(repo=repo, commits_data=load_commit_data())

    yield (
        source_workdir_path,
        parent_dir_path,
        commits,
    )

    # Delete the source repo directory
    delete_dir(source_workdir_path)
 async def m(self, init_mirror, dest_repo_mirror_feature):
     mirror = await init_mirror(
         dest_workdir=dest_repo_mirror_feature.working_dir,
         dest_branch=FEATURE_BRANCH,
     )
     yield mirror
     delete_dir(mirror.dest_repo.working_dir)
Exemple #3
0
def init_chm_test_session():
    """Creates and removes the main directory for the test session."""
    tmp_dir = tempfile.gettempdir()

    # Create the main directory
    parent_dir_path = create_dir(full_path=os.path.join(tmp_dir, PARENT_DIR),
                                 on_conflict="replace")
    yield parent_dir_path

    # Delete the entire main directory
    delete_dir(parent_dir_path)
Exemple #4
0
def chm(init_source_repo):
    """Initializes CommitHistoryMirror session."""
    source_repo_path, parent_dir_path, commit_data = init_source_repo
    mirror = CommitHistoryMirror(source_repo_path)
    yield {
        "mirror": mirror,
        "source_workdir": source_repo_path,
        "parent_dir": parent_dir_path,
        "commits": commit_data,
    }

    # Delete dest working dir
    delete_dir(mirror.dest_repo.working_dir)
Exemple #5
0
def non_git_repo(init_source_repo):
    """Sets up and tears down a directory that is not a git repo."""
    _, parent_dir, _ = init_source_repo

    # Create
    non_git_dir_path = create_dir(
        full_path=os.path.join(tempfile.gettempdir(), "non-git-repo"),
        on_conflict="replace",
    )

    yield non_git_dir_path

    # Delete the non-git repo
    delete_dir(non_git_dir_path)
Exemple #6
0
 def init_dummy_dir(self, init_chm_test_session):
     dummy_dir = os.path.join(init_chm_test_session, DUMMY_DIR)
     if not os.path.exists(dummy_dir):
         os.makedirs(dummy_dir)
     yield dummy_dir, init_chm_test_session
     delete_dir(dummy_dir)
 async def init_cases(self, request, init_mirror, dest_repo_tree):
     options = request.param
     mirror = await init_mirror(dest_workdir=dest_repo_tree.working_dir,
                                **options)
     yield mirror, options
     delete_dir(mirror.dest_repo.working_dir)
 async def m(self, init_mirror, dest_repo_tree):
     mirror = await init_mirror(dest_workdir=dest_repo_tree.working_dir)
     yield mirror
     delete_dir(mirror.dest_repo.working_dir)
 async def m(self, init_mirror, non_git_repo):
     mirror = await init_mirror(dest_workdir=non_git_repo)
     yield mirror
     delete_dir(mirror.dest_repo.working_dir)
 async def m(self, init_mirror):
     mirror = await init_mirror()
     yield mirror
     delete_dir(mirror.dest_repo.working_dir)