diff --git a/setup.cfg b/setup.cfg index f2bce2c..51cb467 100644 --- a/setup.cfg +++ b/setup.cfg @@ -8,3 +8,6 @@ upload-dir = doc/build/html [bdist_rpm] requires = python >= 2.6 + +[aliases] +test = pytest diff --git a/setup.py b/setup.py index 042263f..9a46d48 100644 --- a/setup.py +++ b/setup.py @@ -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'] ) diff --git a/timmy/tests/test_conf.py b/timmy/tests/test_conf.py new file mode 100644 index 0000000..edd3c05 --- /dev/null +++ b/timmy/tests/test_conf.py @@ -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() diff --git a/tox.ini b/tox.ini index 57e7bee..2058a08 100644 --- a/tox.ini +++ b/tox.ini @@ -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}