Adding missing tests

This commit is contained in:
Bill Maxwell 2016-02-01 08:05:57 -07:00
parent bb9f42f700
commit 6a85a36320
4 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,67 @@
import pytest
import cattle
import subprocess
import sys
import os
def _base():
return os.path.dirname(__file__)
def _file(f):
return os.path.join(_base(), '../../{}'.format(f))
class CatalogService(object):
def __init__(self, catalog_bin):
self.catalog_bin = catalog_bin
def assert_retcode(self, ret_code, *args):
p = self.call(*args)
r_code = p.wait()
assert r_code == ret_code
def call(self, *args, **kw):
cmd = [self.catalog_bin]
cmd.extend(args)
kw_args = {
'stdin': subprocess.PIPE,
'stdout': sys.stdout,
'stderr': sys.stderr,
'cwd': _base(),
}
kw_args.update(kw)
return subprocess.Popen(cmd, **kw_args)
@pytest.fixture(scope='session')
def catalog_bin():
c = '/usr/bin/rancher-catalog-service'
assert os.path.exists(c)
return c
@pytest.fixture(scope='session')
def catalog_service(catalog_bin):
return CatalogService(catalog_bin)
@pytest.fixture
def client():
url = 'http://localhost:8088/v1-catalog/schemas'
return cattle.from_env(url=url)
def test_validate_exits_normal(catalog_service):
catalog_service.assert_retcode(
0, '-catalogUrl',
_file('./'),
'-validate', '-port', '18088')
def test_catalog_list(client):
templates = client.list_template()
assert len(templates) > 0

View File

@ -0,0 +1,4 @@
cattle==0.5.1
flake8
pytest==2.3.5

10
integration/setup.py Normal file
View File

@ -0,0 +1,10 @@
from distutils.core import setup
setup(
name='Rancher Catalog YAML Integration Tests',
version='0.1',
packages=[
'core',
],
license='ASL 2.0',
)

12
integration/tox.ini Normal file
View File

@ -0,0 +1,12 @@
[tox]
envlist=flake8, py27
[testenv]
deps=-rrequirements.txt
changedir=core
commands=py.test --duration=20 {posargs}
[testenv:flake8]
deps=-rrequirements.txt
changedir={toxinidir}
commands=flake8 core