diff options
-rw-r--r-- | dovetail/container.py | 10 | ||||
-rw-r--r-- | dovetail/tests/unit/test_parser.py | 7 |
2 files changed, 12 insertions, 5 deletions
diff --git a/dovetail/container.py b/dovetail/container.py index b3450fa3..078d82d9 100644 --- a/dovetail/container.py +++ b/dovetail/container.py @@ -7,6 +7,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 # +import os import utils.dovetail_logger as dt_logger import utils.dovetail_utils as dt_utils @@ -46,8 +47,13 @@ class Container: docker_image = cls.get_docker_image(type) envs = dovetail_config[type]['envs'] opts = dovetail_config[type]['opts'] - creds = ' -v %s:%s ' % (dovetail_config['creds'], - dovetail_config[type]['creds']) + + # if file openstack.creds doesn't exist, creds need to be empty + if os.path.isfile(dovetail_config['creds']): + creds = ' -v %s:%s ' % (dovetail_config['creds'], + dovetail_config[type]['creds']) + else: + creds = '' result_volume = ' -v %s:%s ' % (dovetail_config['result_dir'], dovetail_config[type]['result']['dir']) cmd = 'sudo docker run %s %s %s %s %s %s /bin/bash' % \ diff --git a/dovetail/tests/unit/test_parser.py b/dovetail/tests/unit/test_parser.py index 5fb4dbb9..7047d5ce 100644 --- a/dovetail/tests/unit/test_parser.py +++ b/dovetail/tests/unit/test_parser.py @@ -15,11 +15,13 @@ import logging import os import unittest import yaml +import mock from dovetail import parser from dovetail.utils.dovetail_config import DovetailConfig as dt_cfg +@mock.patch('dovetail.parser.Parser.logger') class TestParser(unittest.TestCase): test_path = os.path.dirname(os.path.realpath(__file__)) @@ -27,10 +29,9 @@ class TestParser(unittest.TestCase): def setUp(self): """Test case setup""" dt_cfg.load_config_files() - parser.Parser.create_log() logging.disable(logging.CRITICAL) - def test_parser_cmd(self): + def test_parser_cmd(self, mock_logger): """Test whether the command is correctly parsed.""" mock_cmd = "python /functest/ci/run_tests.py "\ "-t {{validate_testcase}} -r" @@ -44,7 +45,7 @@ class TestParser(unittest.TestCase): "tempest_smoke_serial -r") self.assertEqual(expected_output, output) - def test_parser_cmd_fail(self): + def test_parser_cmd_fail(self, mock_logger): """Test whether the command is correctly parsed.""" mock_cmd = "python /functest/ci/run_tests.py "\ "-t {{validate_testcase}} -r" |