port more tests

This commit is contained in:
lilydjwg 2020-08-17 16:31:59 +08:00
parent 4887ec66d9
commit 0f9099aae5
14 changed files with 145 additions and 96 deletions

View file

@ -10,13 +10,13 @@ BITBUCKET_MAX_TAG = 'https://bitbucket.org/api/2.0/repositories/%s/refs/tags'
async def get_version(name, conf, *, cache, **kwargs):
repo = conf.get('bitbucket')
br = conf.get('branch', '')
use_max_tag = conf.getboolean('use_max_tag', False)
use_max_tag = conf.get('use_max_tag', False)
ignored_tags = conf.get("ignored_tags", "").split()
sort_version_key = sort_version_keys[conf.get("sort_version_key", "parse_version")]
if use_max_tag:
url = BITBUCKET_MAX_TAG % repo
max_page = conf.getint('max_page', 3)
max_page = conf.get('max_page', 3)
data = await _get_tags(url, max_page=max_page, cache=cache)
else:

View file

@ -26,7 +26,7 @@ def _parse_oldver(oldver):
async def get_version(name, conf, *, cache, **kwargs):
vcs = conf['vcs'] or ''
use_max_tag = conf.getboolean('use_max_tag', False)
use_max_tag = conf.get('use_max_tag', False)
ignored_tags = conf.get("ignored_tags", "").split()
oldver = conf.get('oldver')
cmd = _cmd_prefix + [name, vcs]

View file

@ -1,14 +0,0 @@
# MIT licensed
# Copyright (c) 2013-2017 lilydjwg <lilydjwg@gmail.com>, et al.
import pytest
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
async def test_bitbucket(get_version):
assert await get_version("example", {"bitbucket": "prawee/git-tag"}) == "20150303"
async def test_bitbucket_max_tag(get_version):
assert await get_version("example", {"bitbucket": "prawee/git-tag", "use_max_tag": 1}) == "1.7.0"
async def test_bitbucket_max_tag_with_ignored_tags(get_version):
assert await get_version("example", {"bitbucket": "prawee/git-tag", "use_max_tag": 1, "ignored_tags": "1.6.0 1.7.0"}) == "v1.5"

View file

@ -1,8 +0,0 @@
# MIT licensed
# Copyright (c) 2013-2017 lilydjwg <lilydjwg@gmail.com>, et al.
import pytest
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
async def test_cratesio(get_version):
assert await get_version("example", {"cratesio": None}) == "0.1.0"

View file

@ -1,8 +0,0 @@
# MIT licensed
# Copyright (c) 2013-2017 lilydjwg <lilydjwg@gmail.com>, et al.
import pytest
pytestmark = pytest.mark.asyncio
async def test_manual(get_version):
assert await get_version("example", {"manual": "Meow"}) == "Meow"

View file

@ -1,22 +0,0 @@
# MIT licensed
# Copyright (c) 2017 Felix Yan <felixonmars@archlinux.org>, et al.
from flaky import flaky
import pytest
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
@flaky
async def test_ubuntupkg(get_version):
assert await get_version("sigrok-firmware-fx2lafw", {"ubuntupkg": None}) == "0.1.7-1"
@flaky
async def test_ubuntupkg_strip_release(get_version):
assert await get_version("sigrok-firmware-fx2lafw", {"ubuntupkg": None, "strip-release": 1}) == "0.1.7"
@flaky
async def test_ubuntupkg_suite(get_version):
assert await get_version("sigrok-firmware-fx2lafw", {"ubuntupkg": None, "suite": "xenial"}) == "0.1.2-1"
@flaky
async def test_ubuntupkg_suite_with_paging(get_version):
assert await get_version("ffmpeg", {"ubuntupkg": None, "suite": "xenial"}) == "7:2.8.17-0ubuntu0.1"

View file

@ -1,32 +0,0 @@
# MIT licensed
# Copyright (c) 2013-2017 lilydjwg <lilydjwg@gmail.com>, et al.
import os
import shutil
import pytest
pytestmark = pytest.mark.asyncio
@pytest.mark.skipif(shutil.which("git") is None,
reason="requires git command")
async def test_git(get_version):
os.path.exists("example") or os.mkdir("example")
assert await get_version("example", {"vcs": "git+https://github.com/harry-sanabria/ReleaseTestRepo.git"}) == "1.1.2b3cdf6134b07ae6ac77f11b586dc1ae6d1521db"
@pytest.mark.skipif(shutil.which("hg") is None,
reason="requires hg command")
async def test_mercurial(get_version):
os.path.exists("example") or os.mkdir("example")
assert await get_version("example", {"vcs": "hg+https://bitbucket.org/pil0t/testrepo"}) == "1.1.84679e29c7d9"
@pytest.mark.skipif(shutil.which("git") is None,
reason="requires git command")
async def test_git_max_tag(get_version):
os.path.exists("example") or os.mkdir("example")
assert await get_version("example", {"vcs": "git+https://github.com/harry-sanabria/ReleaseTestRepo.git", "use_max_tag": 1}) == "second_release"
@pytest.mark.skipif(shutil.which("git") is None,
reason="requires git command")
async def test_git_max_tag_with_ignored_tags(get_version):
os.path.exists("example") or os.mkdir("example")
assert await get_version("example", {"vcs": "git+https://github.com/harry-sanabria/ReleaseTestRepo.git", "use_max_tag": 1, "ignored_tags": "second_release release3"}) == "first_release"

View file

@ -1,5 +1,5 @@
# MIT licensed
# Copyright (c) 2013-2017 lilydjwg <lilydjwg@gmail.com>, et al.
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, et al.
from flaky import flaky
import pytest
@ -7,24 +7,29 @@ pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
@flaky
async def test_archpkg(get_version):
assert await get_version("ipw2100-fw", {"archpkg": None}) == "1.3-10"
assert await get_version("ipw2100-fw", {
"source": "archpkg",
}) == "1.3-10"
@flaky
async def test_archpkg_strip_release(get_version):
assert await get_version("ipw2100-fw", {"archpkg": None, "strip-release": 1}) == "1.3"
assert await get_version("ipw2100-fw", {
"source": "archpkg",
"strip_release": True,
}) == "1.3"
@flaky
async def test_archpkg_provided(get_version):
assert await get_version("jsoncpp", {
"archpkg": None,
"source": "archpkg",
"provided": "libjsoncpp.so",
}) == "24-64"
@flaky
async def test_archpkg_provided_strip(get_version):
assert await get_version("jsoncpp", {
"archpkg": None,
"source": "archpkg",
"provided": "libjsoncpp.so",
"strip-release": True,
"strip_release": True,
}) == "24"

26
tests/test_bitbucket.py Normal file
View file

@ -0,0 +1,26 @@
# MIT licensed
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, et al.
import pytest
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
async def test_bitbucket(get_version):
assert await get_version("example", {
"source": "bitbucket",
"bitbucket": "prawee/git-tag",
}) == "20150303"
async def test_bitbucket_max_tag(get_version):
assert await get_version("example", {
"source": "bitbucket",
"bitbucket": "prawee/git-tag",
"use_max_tag": True,
}) == "1.7.0"
async def test_bitbucket_max_tag_with_ignored_tags(get_version):
assert await get_version("example", {
"source": "bitbucket",
"bitbucket": "prawee/git-tag",
"use_max_tag": True,
"ignored_tags": "1.6.0 1.7.0",
}) == "v1.5"

10
tests/test_cratesio.py Normal file
View file

@ -0,0 +1,10 @@
# MIT licensed
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, et al.
import pytest
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
async def test_cratesio(get_version):
assert await get_version("example", {
"source": "cratesio",
}) == "0.1.0"

11
tests/test_manual.py Normal file
View file

@ -0,0 +1,11 @@
# MIT licensed
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, et al.
import pytest
pytestmark = pytest.mark.asyncio
async def test_manual(get_version):
assert await get_version("example", {
"source": "manual",
"manual": "Meow",
}) == "Meow"

View file

@ -1,15 +1,20 @@
# MIT licensed
# Copyright (c) 2019 lilydjwg <lilydjwg@gmail.com>, et al.
# Copyright (c) 2019-2020 lilydjwg <lilydjwg@gmail.com>, et al.
import pytest
pytestmark = [pytest.mark.asyncio,
pytest.mark.needs_net]
async def test_repology(get_version):
assert await get_version("ssed", {"repology": None, "repo": "aur"}) == "3.62"
assert await get_version("ssed", {
"source": "repology",
"repo": "aur",
}) == "3.62"
async def test_repology_no_repo(get_version):
try:
assert await get_version("ssed", {"repology": None}) is None
assert await get_version("ssed", {
"source": "repology",
}) is None
except RuntimeError as e:
assert "repo field is required" in str(e)

34
tests/test_ubuntupkg.py Normal file
View file

@ -0,0 +1,34 @@
# MIT licensed
# Copyright (c) 2020 lilydjwg <lilydjwg@gmail.com>, et al.
# Copyright (c) 2017 Felix Yan <felixonmars@archlinux.org>, et al.
from flaky import flaky
import pytest
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
@flaky
async def test_ubuntupkg(get_version):
assert await get_version("sigrok-firmware-fx2lafw", {
"source": "ubuntupkg",
}) == "0.1.7-1"
@flaky
async def test_ubuntupkg_strip_release(get_version):
assert await get_version("sigrok-firmware-fx2lafw", {
"source": "ubuntupkg",
"strip_release": True,
}) == "0.1.7"
@flaky
async def test_ubuntupkg_suite(get_version):
assert await get_version("sigrok-firmware-fx2lafw", {
"source": "ubuntupkg",
"suite": "xenial",
}) == "0.1.2-1"
@flaky
async def test_ubuntupkg_suite_with_paging(get_version):
assert await get_version("ffmpeg", {
"source": "ubuntupkg",
"suite": "xenial",
}) == "7:2.8.17-0ubuntu0.1"

42
tests/test_vcs.py Normal file
View file

@ -0,0 +1,42 @@
# MIT licensed
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, et al.
import shutil
import pytest
pytestmark = pytest.mark.asyncio
@pytest.mark.skipif(shutil.which("git") is None,
reason="requires git command")
async def test_git(get_version):
assert await get_version("example", {
"source": "vcs",
"vcs": "git+https://github.com/harry-sanabria/ReleaseTestRepo.git",
}) == "1.1.2b3cdf6134b07ae6ac77f11b586dc1ae6d1521db"
@pytest.mark.skipif(shutil.which("hg") is None,
reason="requires hg command")
async def test_mercurial(get_version):
assert await get_version("example", {
"source": "vcs",
"vcs": "hg+https://bitbucket.org/pil0t/testrepo",
}) == "1.1.84679e29c7d9"
@pytest.mark.skipif(shutil.which("git") is None,
reason="requires git command")
async def test_git_max_tag(get_version):
assert await get_version("example", {
"source": "vcs",
"vcs": "git+https://github.com/harry-sanabria/ReleaseTestRepo.git",
"use_max_tag": 1,
}) == "second_release"
@pytest.mark.skipif(shutil.which("git") is None,
reason="requires git command")
async def test_git_max_tag_with_ignored_tags(get_version):
assert await get_version("example", {
"source": "vcs",
"vcs": "git+https://github.com/harry-sanabria/ReleaseTestRepo.git",
"use_max_tag": 1,
"ignored_tags": "second_release release3",
}) == "first_release"