Ejemplo n.º 1
0
def record_git_module(
    _func=None,
    cassette: Optional[Cassette] = None,
):
    decorators = [
        (
            "git.repo.base.Repo.clone_from",
            StoreFiles.where_arg_references(
                key_position_params_dict={"to_path": 2},
                output_cls=Repo,
                cassette=cassette,
            ),
        ),
        (
            "git.remote.Remote.push",
            PushInfoStorageList.decorator_plain(),
        ),
        ("git.remote.Remote.fetch", FetchInfoStorageList.decorator_plain()),
        ("git.remote.Remote.pull", FetchInfoStorageList.decorator_plain()),
    ]
    record_git_decorator = replace_module_match_with_multiple_decorators(
        *decorators,
        cassette=cassette,
    )

    if _func is not None:
        return record_git_decorator(_func)
    else:
        return record_git_decorator
Ejemplo n.º 2
0
    replace_module_match(
        what="packit.fedpkg.FedPKG.clone",
        decorate=StoreFiles.where_arg_references(
            key_position_params_dict={"target_path": 2}),
    ))
@apply_decorator_to_all_methods(
    replace_module_match(
        what="git.repo.base.Repo.clone_from",
        decorate=StoreFiles.where_arg_references(
            key_position_params_dict={"to_path": 2},
            return_decorator=Repo.decorator_plain,
        ),
    ))
@apply_decorator_to_all_methods(
    replace_module_match(what="git.remote.Remote.push",
                         decorate=PushInfoStorageList.decorator_plain()))
@apply_decorator_to_all_methods(
    replace_module_match(what="git.remote.Remote.fetch",
                         decorate=FetchInfoStorageList.decorator_plain()))
@apply_decorator_to_all_methods(
    replace_module_match(what="tempfile.mkdtemp", decorate=TempFile.mkdtemp()))
@apply_decorator_to_all_methods(
    replace_module_match(what="tempfile.mktemp", decorate=TempFile.mktemp()))
# Be aware that decorator stores login and token to test_data, replace it by some value.
# Default precommit hook doesn't do that for copr.v3.helpers, see README.md
@apply_decorator_to_all_methods(
    replace_module_match(what="copr.v3.helpers.config_from_file",
                         decorate=Simple.decorator_plain()))
class ProposeUpdate(PackitTest):
    def cassette_setup(self, cassette):
        cassette.data_miner.data_type = DataTypes.Dict
Ejemplo n.º 3
0
            key_position_params_dict={"target_path": 2}
        ),
    )
)
@apply_decorator_to_all_methods(
    replace_module_match(
        what="git.repo.base.Repo.clone_from",
        decorate=StoreFiles.where_arg_references(
            key_position_params_dict={"to_path": 2},
            return_decorator=Repo.decorator_plain,
        ),
    )
)
@apply_decorator_to_all_methods(
    replace_module_match(
        what="git.remote.Remote.push", decorate=PushInfoStorageList.decorator_plain()
    )
)
@apply_decorator_to_all_methods(
    replace_module_match(
        what="git.remote.Remote.fetch", decorate=FetchInfoStorageList.decorator_plain()
    )
)
@apply_decorator_to_all_methods(
    replace_module_match(what="tempfile.mkdtemp", decorate=TempFile.mkdtemp())
)
@apply_decorator_to_all_methods(
    replace_module_match(what="tempfile.mktemp", decorate=TempFile.mktemp())
)
# Be aware that decorator stores login and token to test_data, replace it by some value.
# Default precommit hook doesn't do that for copr.v3.helpers, see README.md
Ejemplo n.º 4
0
        what="Session.send",
        decorator=RequestResponseHandling.decorator(item_list=[]),
    ).replace_module(
        where="^tempfile$", who_name="^packit", replacement=TempFile).decorate(
            where="^packit$",
            who_name="fedpkg",
            what="utils.run_command_remote",
            decorator=store_function_output,
        ).decorate(
            where="fedpkg",
            what="FedPKG.clone",
            decorator=StoreFiles.arg_references(
                files_params={"target_path": 2}),
        ).decorate(
            where="git",
            who_name="local_project",
            what="remote.Remote.push",
            decorator=PushInfoStorageList.decorator(item_list=[]),
        ).decorate(  # ogr
            where="^requests$",
            what="Session.send",
            who_name=[
                "ogr.services.pagure",
                "gitlab",
                "github.MainClass",
                "github.Requester",
                "ogr.services.github_tweak",
            ],
            decorator=RequestResponseHandling.decorator(item_list=[]),
        ))