Merge pull request #31 from felixonmars/tests

Add more tests
This commit is contained in:
依云 2015-11-05 22:02:19 +08:00
commit 29b0fe7e2d
5 changed files with 39 additions and 2 deletions

View file

@ -1,7 +1,7 @@
from . import cmd
def get_version(name, conf, callback):
referree = conf['pacman']
referree = conf.get('pacman') or name
c = "LANG=C pacman -Si %s | grep -F Version | awk '{print $3}'" % referree
conf['cmd'] = c

View file

@ -27,7 +27,7 @@ def _parse_oldver(oldver):
def get_version(name, conf, callback):
vcs = conf['vcs']
oldver = conf['oldver']
oldver = conf.get('oldver')
cmd = _cmd_prefix + [name, vcs]
p = tornado.process.Subprocess(cmd, io_loop=IOLoop.instance(),
stdout=tornado.process.Subprocess.STREAM)

6
tests/test_gitcafe.py Normal file
View file

@ -0,0 +1,6 @@
from tests.helper import ExternalVersionTestCase
class GitCafeTest(ExternalVersionTestCase):
def test_gitcafe(self):
self.assertEqual(self.sync_get_version("example", {"gitcafe": "test/test"}), "20120201")

13
tests/test_pacman.py Normal file
View file

@ -0,0 +1,13 @@
import shutil
import pytest
from tests.helper import ExternalVersionTestCase
@pytest.mark.skipif(shutil.which("pacman") is None,
reason="requires pacman command")
class PacmanTest(ExternalVersionTestCase):
def test_pacman(self):
self.assertEqual(self.sync_get_version("ipw2100-fw", {"pacman": None}), "1.3-7")
def test_pacman_strip_release(self):
self.assertEqual(self.sync_get_version("ipw2100-fw", {"pacman": None, "strip-release": 1}), "1.3")

18
tests/test_vcs.py Normal file
View file

@ -0,0 +1,18 @@
import os
import shutil
import pytest
from tests.helper import ExternalVersionTestCase
class VCSTest(ExternalVersionTestCase):
@pytest.mark.skipif(shutil.which("git") is None,
reason="requires git command")
def test_git(self):
os.path.exists("example") or os.mkdir("example")
self.assertEqual(self.sync_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")
def test_mercurial(self):
os.path.exists("example") or os.mkdir("example")
self.assertEqual(self.sync_get_version("example", {"vcs": "hg+https://bitbucket.org/pil0t/testrepo"}), "1.1.84679e29c7d9")