Adding oslotest to improve debugging
oslotest includes things like showing log messages/stdout on test errors, which makes debugging much easier. Also moved mock to second group in imports, as it's a 3rd party library. Change-Id: I016ae0a376d42dec28085687ea7194df4cd44eda
This commit is contained in:
parent
74ba66568e
commit
1a87ebfcce
@ -1,15 +0,0 @@
|
||||
"""
|
||||
Copyright 2013 Rackspace, 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.
|
||||
"""
|
@ -16,9 +16,9 @@ limitations under the License.
|
||||
|
||||
import json
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
from oslotest import base as test_base
|
||||
import pkg_resources
|
||||
from stevedore import extension
|
||||
from wsgiref import simple_server
|
||||
@ -45,8 +45,9 @@ class FakeExtension(base.BaseAgentExtension):
|
||||
super(FakeExtension, self).__init__('FAKE')
|
||||
|
||||
|
||||
class TestHeartbeater(unittest.TestCase):
|
||||
class TestHeartbeater(test_base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(TestHeartbeater, self).setUp()
|
||||
self.mock_agent = mock.Mock()
|
||||
self.heartbeater = agent.IronicPythonAgentHeartbeater(self.mock_agent)
|
||||
self.heartbeater.api = mock.Mock()
|
||||
@ -118,8 +119,9 @@ class TestHeartbeater(unittest.TestCase):
|
||||
self.assertEqual(self.heartbeater.error_delay, 2.7)
|
||||
|
||||
|
||||
class TestBaseAgent(unittest.TestCase):
|
||||
class TestBaseAgent(test_base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(TestBaseAgent, self).setUp()
|
||||
self.encoder = encoding.RESTJSONEncoder(indent=4)
|
||||
self.agent = agent.IronicPythonAgent('https://fake_api.example.'
|
||||
'org:8081/',
|
||||
@ -244,9 +246,10 @@ class TestBaseAgent(unittest.TestCase):
|
||||
self.assertEqualEncoded(result, expected_result)
|
||||
|
||||
|
||||
class TestAgentCmd(unittest.TestCase):
|
||||
class TestAgentCmd(test_base.BaseTestCase):
|
||||
@mock.patch('ironic_python_agent.openstack.common.log.getLogger')
|
||||
@mock.patch('__builtin__.open')
|
||||
def test__get_kernel_params_fail(self, open_mock):
|
||||
def test__get_kernel_params_fail(self, logger_mock, open_mock):
|
||||
open_mock.side_effect = Exception
|
||||
params = agent_cmd._get_kernel_params()
|
||||
self.assertEqual(params, {})
|
||||
@ -258,7 +261,6 @@ class TestAgentCmd(unittest.TestCase):
|
||||
open_mock.return_value.__exit__ = mock.Mock()
|
||||
read_mock = open_mock.return_value.read
|
||||
read_mock.return_value = kernel_line
|
||||
|
||||
params = agent_cmd._get_kernel_params()
|
||||
self.assertEqual(params['api-url'], 'http://localhost:9999')
|
||||
self.assertEqual(params['foo'], 'bar')
|
||||
|
@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
"""
|
||||
|
||||
import mock
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
from oslotest import base as test_base
|
||||
import pecan
|
||||
import pecan.testing
|
||||
|
||||
@ -28,7 +28,7 @@ from ironic_python_agent import base
|
||||
PATH_PREFIX = '/v1'
|
||||
|
||||
|
||||
class TestIronicAPI(unittest.TestCase):
|
||||
class TestIronicAPI(test_base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestIronicAPI, self).setUp()
|
||||
@ -36,6 +36,7 @@ class TestIronicAPI(unittest.TestCase):
|
||||
self.app = self._make_app(self.mock_agent)
|
||||
|
||||
def tearDown(self):
|
||||
super(TestIronicAPI, self).tearDown()
|
||||
pecan.set_config({}, overwrite=True)
|
||||
|
||||
def _make_app(self, enable_acl=False):
|
||||
|
@ -18,15 +18,17 @@ from __future__ import unicode_literals
|
||||
|
||||
import base64
|
||||
import json
|
||||
|
||||
import mock
|
||||
import unittest
|
||||
from oslotest import base as test_base
|
||||
|
||||
from ironic_python_agent import configdrive
|
||||
from ironic_python_agent import utils
|
||||
|
||||
|
||||
class ConfigDriveWriterTestCase(unittest.TestCase):
|
||||
class ConfigDriveWriterTestCase(test_base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(ConfigDriveWriterTestCase, self).setUp()
|
||||
self.writer = configdrive.ConfigDriveWriter()
|
||||
self.maxDiff = None
|
||||
|
||||
|
@ -13,14 +13,14 @@ 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 oslotest import base as test_base
|
||||
|
||||
from ironic_python_agent import decom
|
||||
|
||||
|
||||
class TestDecomExtension(unittest.TestCase):
|
||||
class TestDecomExtension(test_base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(TestDecomExtension, self).setUp()
|
||||
self.agent_extension = decom.DecomExtension()
|
||||
|
||||
def test_decom_extension(self):
|
||||
|
@ -15,13 +15,14 @@ limitations under the License.
|
||||
"""
|
||||
|
||||
import mock
|
||||
import unittest
|
||||
from oslotest import base as test_base
|
||||
|
||||
from ironic_python_agent import hardware
|
||||
|
||||
|
||||
class TestGenericHardwareManager(unittest.TestCase):
|
||||
class TestGenericHardwareManager(test_base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(TestGenericHardwareManager, self).setUp()
|
||||
self.hardware = hardware.GenericHardwareManager()
|
||||
|
||||
@mock.patch('os.listdir')
|
||||
|
@ -15,16 +15,16 @@ limitations under the License.
|
||||
"""
|
||||
|
||||
import json
|
||||
import mock
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import mock
|
||||
from oslotest import base as test_base
|
||||
|
||||
from ironic_python_agent import errors
|
||||
from ironic_python_agent import hardware
|
||||
from ironic_python_agent import ironic_api_client
|
||||
from ironic_python_agent.openstack.common import loopingcall
|
||||
|
||||
|
||||
API_URL = 'http://agent-api.ironic.example.org/'
|
||||
|
||||
|
||||
@ -36,8 +36,9 @@ class FakeResponse(object):
|
||||
self.headers = headers or {}
|
||||
|
||||
|
||||
class TestBaseIronicPythonAgent(unittest.TestCase):
|
||||
class TestBaseIronicPythonAgent(test_base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(TestBaseIronicPythonAgent, self).setUp()
|
||||
self.api_client = ironic_api_client.APIClient(API_URL)
|
||||
self.hardware_info = [
|
||||
hardware.HardwareInfo(hardware.HardwareType.MAC_ADDRESS,
|
||||
|
@ -15,14 +15,15 @@ limitations under the License.
|
||||
"""
|
||||
|
||||
import mock
|
||||
import unittest
|
||||
from oslotest import base as test_base
|
||||
|
||||
from ironic_python_agent import errors
|
||||
from ironic_python_agent import standby
|
||||
|
||||
|
||||
class TestStandbyExtension(unittest.TestCase):
|
||||
class TestStandbyExtension(test_base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(TestStandbyExtension, self).setUp()
|
||||
self.agent_extension = standby.StandbyExtension()
|
||||
|
||||
def test_standby_extension(self):
|
||||
|
@ -6,5 +6,6 @@ module=gettextutils
|
||||
module=log
|
||||
module=loopingcall
|
||||
module=processutils
|
||||
|
||||
# The base module to hold the copy of openstack.common
|
||||
base=ironic_python_agent
|
||||
|
@ -8,3 +8,4 @@ eventlet>=0.13.0
|
||||
oslo.config>=1.2.0
|
||||
Babel>=1.3
|
||||
iso8601>=0.1.9
|
||||
oslotest==1.0
|
Loading…
Reference in New Issue
Block a user