Merge pull request #21 from felixonmars/tests

Add testcases
This commit is contained in:
依云 2015-11-04 19:32:15 +08:00
commit 66123fbe9f
6 changed files with 34 additions and 0 deletions

7
.travis.yml Normal file
View File

@ -0,0 +1,7 @@
sudo: false
language: python
python:
- "3.4"
- "3.5"
install: pip install .
script: py.test

View File

@ -1,5 +1,7 @@
**nvchecker** (short for *new version checker*) is for checking if a new version of some software has been released.
[![Build Status](https://travis-ci.org/lilydjwg/nvchecker.svg)](https://travis-ci.org/lilydjwg/nvchecker)
Dependency
==========
- Python 3

View File

@ -9,6 +9,9 @@ setup(
version = nvchecker.__version__,
packages = find_packages(),
install_requires = ['tornado', 'setuptools'],
tests_require=[
'pytest',
],
entry_points = {
'console_scripts': [
'nvchecker = nvchecker.main:main',

0
tests/__init__.py Normal file
View File

16
tests/helper.py Normal file
View File

@ -0,0 +1,16 @@
from nvchecker.get_version import get_version
import tornado.testing
class ExternalVersionTestCase(tornado.testing.AsyncTestCase):
def sync_get_version(self, name, config):
result = {}
def get_version_callback(name, version):
result["version"] = version
self.stop()
get_version(name, config, get_version_callback)
self.wait()
return result["version"]

6
tests/test_npm.py Normal file
View File

@ -0,0 +1,6 @@
from tests.helper import ExternalVersionTestCase
class NPMTest(ExternalVersionTestCase):
def test_npm(self):
self.assertEqual(self.sync_get_version("example", {"npm": None}), "0.0.0")