Beispiel #1
0
def info_package(pearl_env: PearlEnvironment, package: Package,
                 args: Namespace):
    """
    Provide info about a package.
    """
    requires = pearl_env.required_by(package)
    messenger.print(
        dedent("""
        {cyan}Name{normal}: {full_name}
        {cyan}Description{normal}: {description}
        {cyan}Homepage{normal}: {homepage}
        {cyan}URL{normal}: {url}
        {cyan}Author{normal}: {author}
        {cyan}License{normal}: {license}
        {cyan}Operating Systems{normal}: {os}
        {cyan}Keywords{normal}: {keywords}
        {cyan}Installed{normal}: {installed}
        {cyan}Pkg Directory{normal}: {pkg_dir}
        {cyan}Var Directory{normal}: {var_dir}
        {cyan}Depends on{normal}: {depends}
        {cyan}Required by{normal}: {requires}
        """.format(
            cyan=Color.CYAN,
            normal=Color.NORMAL,
            full_name=package.full_name,
            description=package.description,
            homepage=package.homepage,
            url=package.url,
            author=package.author,
            license=package.license,
            os=tuple(o.name.lower() for o in package.os),
            keywords=package.keywords,
            installed=package.is_installed(),
            pkg_dir=package.dir,
            var_dir=package.vardir,
            depends=tuple(d.full_name for d in package.depends),
            requires=tuple(r.full_name for r in requires),
        )))
    return package, requires
Beispiel #2
0
def test_lookup_package_not_in_repo(tmp_path):
    home_dir = create_pearl_home(tmp_path)
    packages_info = {
        "repo-test": {
            "pkg-test": {
                "repo_name": "repo-test",
                "name": "pkg-test",
                "url": "/blah",
            },
        }
    }
    builder = PackageBuilder(home_dir)
    packages = builder.build_packages(packages_info)

    pearl_env = PearlEnvironment(home_dir, env_initialized=False)
    pearl_env._packages = packages
    with pytest.raises(PackageNotInRepoError):
        pearl_env.lookup_package('repo-test/pkg-a-test')

    with pytest.raises(PackageNotInRepoError):
        pearl_env.lookup_package('pkg-a-test')
Beispiel #3
0
def test_config_filename_not_a_file(tmp_path):
    with pytest.raises(ValueError):
        PearlEnvironment._get_config_filename(tmp_path, True)
Beispiel #4
0
def test_config_filename_does_not_exist():
    with pytest.raises(ValueError):
        PearlEnvironment._get_config_filename(Path('/myhome2/pearl.conf'),
                                              True)
Beispiel #5
0
def test_config_filename():
    assert PearlEnvironment._get_config_filename(
        Path('/myhome2/pearl.conf'), False) == Path('/myhome2/pearl.conf')
    assert PearlEnvironment._get_config_filename(None, False) == Path(
        '{}/.config/pearl/pearl.conf'.format(os.environ['HOME']))
Beispiel #6
0
def test_pearl_env_home_not_directory(tmp_path):
    (tmp_path / 'file').touch()
    with pytest.raises(ValueError):
        PearlEnvironment._get_home(tmp_path / 'file')
Beispiel #7
0
def test_pearl_env_home_not_exist():
    with mock.patch(_MODULE_UNDER_TEST + '.os') as os_mock:
        os_mock.environ = {'HOME': '/home/myhome'}
        PearlEnvironment._get_home(env_initialized=False)
        with pytest.raises(ValueError):
            PearlEnvironment._get_home()