Ejemplo n.º 1
0
def test_tool_requirements():
    tool_requirements_ab = ToolRequirements([REQUIREMENT_A, REQUIREMENT_B])
    tool_requirements_ab_dup = ToolRequirements([REQUIREMENT_A, REQUIREMENT_B])
    tool_requirements_b = ToolRequirements([REQUIREMENT_A])
    assert tool_requirements_ab == ToolRequirements(
        [REQUIREMENT_B, REQUIREMENT_A])
    assert tool_requirements_ab == ToolRequirements(
        [REQUIREMENT_B, REQUIREMENT_A, REQUIREMENT_A])
    assert tool_requirements_ab != tool_requirements_b
    assert len({tool_requirements_ab, tool_requirements_ab_dup}) == 1
Ejemplo n.º 2
0
def get_dependencies(builder: "HasReqsHints") -> ToolRequirements:
    (software_requirement, _) = builder.get_requirement("SoftwareRequirement")
    dependencies = []  # type: List[ToolRequirement]
    if software_requirement and software_requirement.get("packages"):
        packages = cast(
            MutableSequence[MutableMapping[str, Union[str,
                                                      MutableSequence[str]]]],
            software_requirement.get("packages"),
        )
        for package in packages:
            version = package.get("version", None)
            if isinstance(version, MutableSequence):
                if version:
                    version = version[0]
                else:
                    version = None
            specs = [{"uri": s} for s in package.get("specs", [])]
            dependencies.append(
                ToolRequirement.from_dict(
                    dict(
                        name=cast(str, package["package"]).split("#")[-1],
                        version=version,
                        type="package",
                        specs=specs,
                    )))

    return ToolRequirements.from_list(dependencies)
Ejemplo n.º 3
0
 def __init__(self, requirements=None, installed_tool_dependencies=None):
     requirements = requirements or ToolRequirements()
     if installed_tool_dependencies is None:
         installed_tool_dependencies = []
     self.requirements = requirements
     # tool shed installed tool dependencies...
     self.installed_tool_dependencies = installed_tool_dependencies
Ejemplo n.º 4
0
    def from_dict(as_dict):
        if as_dict is None:
            return None

        requirements_dicts = as_dict.get('requirements', [])
        requirements = ToolRequirements.from_list(requirements_dicts)
        installed_tool_dependencies_dicts = as_dict.get(
            'installed_tool_dependencies', [])
        installed_tool_dependencies = map(
            DependenciesDescription._toolshed_install_dependency_from_dict,
            installed_tool_dependencies_dicts)
        return DependenciesDescription(
            requirements=requirements,
            installed_tool_dependencies=installed_tool_dependencies)
Ejemplo n.º 5
0
def test_shell_commands_built():
    # Test that dependency manager builds valid shell commands for a list of
    # requirements.
    with __test_base_path() as base_path:
        dm = __dependency_manager_for_base_path(default_base_path=base_path)
        __setup_galaxy_package_dep(base_path,
                                   TEST_REPO_NAME,
                                   TEST_VERSION,
                                   contents="export FOO=\"bar\"")
        mock_requirements = ToolRequirements([{
            'type': 'package',
            'version': TEST_VERSION,
            'name': TEST_REPO_NAME
        }])
        commands = dm.dependency_shell_commands(mock_requirements)
        __assert_foo_exported(commands)