Add first test and update setup and tox to use it

Change-Id: Ife7d37588523029335045f9c647e1eaaf463a66e
This commit is contained in:
Dmitry Sutyagin 2016-09-14 18:16:08 +03:00
parent a4fed99239
commit 2a5c51572b
4 changed files with 69 additions and 3 deletions

View File

@ -8,3 +8,6 @@ upload-dir = doc/build/html
[bdist_rpm]
requires = python >= 2.6
[aliases]
test = pytest

View File

@ -48,4 +48,6 @@ setup(name=pname,
data_files=rqfiles,
include_package_data=package_data,
entry_points={'console_scripts': ['%s=%s.cli:main' % (pname, pname)]},
setup_requires=['pytest-runner'],
tests_require=['pytest']
)

63
timmy/tests/test_conf.py Normal file
View File

@ -0,0 +1,63 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Copyright 2015 Mirantis, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import unittest
from timmy import conf
class ConfTest(unittest.TestCase):
def test_param_presence_and_types(self):
param_types = {
'hard_filter': dict,
'soft_filter': dict,
'ssh_opts': list,
'env_vars': list,
'timeout': int,
'prefix': str,
'rqdir': str,
'rqfile': list,
'compress_timeout': int,
'outdir': str,
'archive_dir': str,
'archive_name': str,
'outputs_timestamp': bool,
'dir_timestamp': bool,
'put': list,
'cmds': list,
'scripts': list,
'files': list,
'filelists': list,
'logs': list,
'logs_no_default': bool,
'logs_exclude_filtered': bool,
'logs_days': int,
'logs_speed_limit': bool,
'logs_speed_default': int,
'logs_speed': int,
'logs_size_coefficient': float,
'shell_mode': bool,
'do_print_results': bool,
'clean': bool
}
config = conf.load_conf(None)
for key in param_types:
self.assertEqual(type(config[key]), param_types[key])
if __name__ == '__main__':
unittest.main()

View File

@ -9,9 +9,7 @@ install_command = pip install {opts} {packages}
setenv =
VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/test-requirements.txt
#commands = python setup.py test --slowest --testr-args='{posargs}'
# For now:
commands = true
commands = python setup.py test
[testenv:pep8]
commands = flake8 {posargs}