Fixed deps in setup.py and a bug in tests

Currently the deps of oslo.i18n wasn't aligned with
Kilo global-requirements.

Now tests are not execute by runtests.py but tox
call directly py.test, as there was a bug in the exec
of runtests.py. This is a temporary solution as
testr will be used soon as testing framework

Close bug: 1498078

Change-Id: I07daddb14ab75fe089c98c8e00c24ecb550ada82
This commit is contained in:
Fausto Marzi 2015-09-21 17:21:02 +01:00 committed by Saad Zaher
parent fd3cbba2b1
commit f7841f840c
6 changed files with 18 additions and 19 deletions

@ -35,10 +35,10 @@ from freezer.main import freezer_main, fail
if __name__ == '__main__':
try:
freezer_main()
backup_args = freezer_main()
except ValueError as err:
fail(1, err)
fail(1, err, quiet=backup_args.quiet)
except ImportError as err:
fail(1, err)
fail(1, err, quiet=backup_args.quiet)
except Exception as err:
fail(1, err)
fail(1, err, quiet=backup_args.quiet)

@ -40,13 +40,12 @@ from freezer import winutils
# Initialize backup options
from freezer.validator import Validator
(backup_args, arg_parse) = backup_arguments()
def freezer_main(args={}):
"""Freezer main loop for job execution.
"""
global backup_args, arg_parse
(backup_args, arg_parse) = backup_arguments()
def configure_log_file_using_defaults():
""" Configure log file for freezer """
@ -110,7 +109,7 @@ def freezer_main(args={}):
try:
log_file_name = configure_log_file_using_defaults()
except Exception as err:
fail(1, err, do_log=False)
fail(1, err, quiet=backup_args.quiet, do_log=False)
if not backup_args.quiet:
logging.info('log file at {0}'.format(log_file_name))
@ -174,10 +173,10 @@ def freezer_main(args={}):
return backup_args
def fail(exit_code, e, do_log=True):
def fail(exit_code, e, quiet=False, do_log=True):
""" Catch the exceptions and write it to log """
msg = '[*] Critical Error: {0}\n'.format(e)
if not backup_args.quiet:
if quiet:
sys.stderr.write(msg)
if do_log:
logging.critical(msg)

@ -85,7 +85,8 @@ setup(
'python-glanceclient>=0.15.0,<0.18.0',
'python-novaclient>=2.22.0,<2.24.0',
'python-openstackclient>=1.0.3,<1.1.0',
'oslo.utils>=1.4.0,<1.5.0',
'oslo.utils>=1.4.0,!=1.4.1,<1.5.0',
'oslo.i18n>=1.5.0,<1.6.0',
'PyMySQL>=0.6.2',
'pymongo>=2.6.3,<3.0',
'apscheduler',

@ -1168,7 +1168,7 @@ class FakeSys:
@staticmethod
def fake_sys_argv():
return [1, 2, 3]
return ['', '', '']
# @staticmethod
def fake_sys_exit(self, status_code):

@ -17,16 +17,13 @@ limitations under the License.
This product includes cryptographic software written by Eric Young
(eay@cryptsoft.com). This product includes software written by Tim
Hudson (tjh@cryptsoft.com).
========================================================================
"""
from commons import fake_create_job
from commons import FakeSys
from commons import BackupOpt1
from freezer.main import freezer_main
from freezer import job
from freezer.main import freezer_main
import pytest
import sys
@ -37,7 +34,9 @@ def test_freezer_main(monkeypatch):
monkeypatch.setattr(sys, 'exit', fake_sys.fake_sys_exit)
with pytest.raises(SystemExit):
freezer_main()
monkeypatch.setattr(job, 'create_job', fake_create_job)
monkeypatch.setattr(sys, 'argv', FakeSys.fake_sys_argv())
assert freezer_main() is not None
# assert freezer_main() is not None
with pytest.raises(SystemExit):
freezer_main()

@ -30,7 +30,7 @@ passenv =
install_command = pip install -U {opts} {packages}
setenv = VIRTUAL_ENV={envdir}
commands = python runtests.py -v -n 2 --cov-report term-missing --cov freezer
commands = py.test -v --cov-report term-missing --cov freezer
[pytest]
python_files = test_*.py