def test_pkg_version():

    # version specified, but not bioc version
    b = bioconductor_skeleton.BioCProjectPage('DESeq2', pkg_version='1.14.1')
    assert b.version == '1.14.1'
    assert b.bioc_version == '3.4'
    assert b.bioconductor_tarball_url == (
        'http://bioconductor.org/packages/3.4/bioc/src/contrib/DESeq2_1.14.1.tar.gz'
    )
    assert b.bioarchive_url is None
    assert b.cargoport_url == (
        'https://depot.galaxyproject.org/software/bioconductor-deseq2/bioconductor-deseq2_1.14.1_src_all.tar.gz'
    )  # noqa: E501: line too long

    # bioc version specified, but not package version
    b = bioconductor_skeleton.BioCProjectPage('edgeR', bioc_version='3.5')
    assert b.version == '3.18.1'
    assert b.bioc_version == '3.5'
    assert b.bioconductor_tarball_url == (
        'http://bioconductor.org/packages/3.5/bioc/src/contrib/edgeR_3.18.1.tar.gz'
    )
    assert b.bioarchive_url is None
    assert b.cargoport_url == (
        'https://depot.galaxyproject.org/software/bioconductor-edger/bioconductor-edger_3.18.1_src_all.tar.gz'
    )  # noqa: E501: line too long
def test_bioarchive_exists_but_not_bioconductor():
    """
    BioCProjectPage init tries to find the package on the bioconductor site.
    Sometimes bioaRchive has cached the tarball but it no longer exists on the
    bioconductor site. In those cases, we're raising a PackageNotFoundError.

    It's possible to build a recipe based on a package only found in
    bioarchive, but I'm not sure we want to support that in an automated
    fashion. In those cases it would be best to build the recipe manually.
    """
    with pytest.raises(bioconductor_skeleton.PackageNotFoundError):
        bioconductor_skeleton.BioCProjectPage('BioBase', pkg_version='2.37.2')
def test_find_best_bioc_version():

    assert bioconductor_skeleton.find_best_bioc_version('DESeq2', '1.14.1') == '3.4'

    # Non-existent version:
    with pytest.raises(bioconductor_skeleton.PackageNotFoundError):
        bioconductor_skeleton.find_best_bioc_version('DESeq2', '5000')

    # Version existed at some point in the past, but only exists now on
    # bioaRchive:
    with pytest.raises(bioconductor_skeleton.PackageNotFoundError):
        bioconductor_skeleton.BioCProjectPage('BioBase', pkg_version='2.37.2')
def test_bioarchive_exists():
    # package found on both bioconductor and bioarchive.
    b = bioconductor_skeleton.BioCProjectPage('DESeq', pkg_version='1.26.0')
    assert b.bioarchive_url == 'https://bioarchive.galaxyproject.org/DESeq_1.26.0.tar.gz'