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(set([tool_requirements_ab, tool_requirements_ab_dup])) == 1
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)
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 )
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)
def get_dependencies(builder): # type: (HasReqsHints) -> ToolRequirements (software_requirement, _) = builder.get_requirement("SoftwareRequirement") dependencies = [] # type: List[ToolRequirement] if software_requirement and software_requirement.get("packages"): packages = 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=package["package"].split("#")[-1], version=version, type="package", specs=specs, ))) return ToolRequirements.from_list(dependencies)