Ejemplo 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.')
Ejemplo n.º 2
0
def test_create_package_pearl_config_exists(tmp_path):
    dest_dir = tmp_path / 'new-pkg'
    (dest_dir / 'pearl-config').mkdir(parents=True)
    config_file = tmp_path / 'pearl.conf'

    pearl_env = mock.Mock()
    pearl_env.config_filename = config_file

    with pytest.raises(RuntimeError):
        create_package(
            pearl_env,
            PackageArgs(
                name="mypkg",
                dest_dir=dest_dir
            )
        )
Ejemplo n.º 3
0
def test_create_package(tmp_path):
    dest_dir = tmp_path / 'new-pkg'
    dest_dir.mkdir(parents=True)
    config_file = tmp_path / 'pearl.conf'

    pearl_env = mock.Mock()
    pearl_env.config_filename = config_file

    create_package(
        pearl_env,
        PackageArgs(
            name="mypkg",
            dest_dir=dest_dir
        )
    )

    assert (dest_dir / 'pearl-config').exists()
    assert config_file.read_text() == 'PEARL_PACKAGES["mypkg"] = {{"url": "{}"}}\n'.format(dest_dir)