Exemplo n.º 1
0
def _pearl(pearl_env: PearlEnvironment, args):
    command = PearlCommand.from_string(args.command)
    if hasattr(args, 'packages'):
        args.packages = _extract_packages(pearl_env, command, args)

    if command == PearlCommand.INIT:
        syst.init_pearl(pearl_env, args)
    elif command == PearlCommand.INSTALL:
        pack.install_packages(pearl_env, args)
    elif command == PearlCommand.UPDATE:
        if not args.packages:
            syst.update_pearl(pearl_env, args)
        else:
            pack.update_packages(pearl_env, args)
    elif command == PearlCommand.REMOVE:
        if not args.packages:
            syst.remove_pearl(pearl_env, args)
        else:
            pack.remove_packages(pearl_env, args)
    elif command == PearlCommand.EMERGE:
        pack.emerge_packages(pearl_env, args)
    elif command == PearlCommand.INFO:
        pack.info_packages(pearl_env, args)
    elif command == PearlCommand.LIST:
        pack.list_packages(pearl_env, args)
    elif command == PearlCommand.SEARCH:
        pack.list_packages(pearl_env, args)
    elif command == PearlCommand.CREATE:
        pack.create_package(pearl_env, args)
    else:
        raise ValueError(
            'No command specified. Run "pearl --help" for list of commands.')
Exemplo n.º 2
0
def update_pearl(pearl_env: PearlEnvironment, args: Namespace):
    """Updates the Pearl environment."""
    package_list = []
    for repo_name, repo_packages in pearl_env.packages.items():
        for _, package in repo_packages.items():
            if package.is_installed():
                package_list.append(package)
    args.packages = package_list
    update_packages(pearl_env, args=args)
Exemplo n.º 3
0
def test_update_packages(tmp_path):
    home_dir = create_pearl_home(tmp_path)

    packages_info = {
        "repo-test": {
            "pkg1": {
                "repo_name": "repo-test",
                "name": "pkg1",
                "url": "/blah",
                "depends": ["repo-test/deppkg1"]
            },
            "pkg2": {
                "repo_name": "repo-test",
                "name": "pkg2",
                "url": "/blah",
                "depends": []
            },
            "deppkg1": {
                "repo_name": "repo-test",
                "name": "deppkg1",
                "url": "/blah",
                "depends": []
            }
        }
    }
    builder = PackageBuilder(home_dir)
    packages = builder.build_packages(packages_info)
    pearl_env = PearlEnvironment(
        home_dir, env_initialized=False
    )
    pearl_env._packages = packages

    with mock.patch(_MODULE_UNDER_TEST + '.update_package') as update_mock, \
            mock.patch(_MODULE_UNDER_TEST + '.emerge_package') as emerge_mock:
        args = PackageArgs(packages=[packages['repo-test']['pkg1'], packages['repo-test']['pkg2']])
        update_packages(pearl_env, args)

        emerge_mock.assert_has_calls([mock.call(mock.ANY, packages['repo-test']['deppkg1'], args)])
        update_mock.assert_has_calls([mock.call(mock.ANY, packages['repo-test']['pkg1'], args), mock.call(mock.ANY, packages['repo-test']['pkg2'], args)])