All tests in fuel_agent use unittest2 now
unittest2 backports some nice features from newer versions of unittest for python 2.7 (like assertRaises context manager). Moreover tests now are using either oslotest or testtools directly, switching to one test framework is going to simplify tests. Change-Id: Ibce9403b20958f9db2a59db9c6b7479a4fc57857 Implements blueprint: volume-manager-refactoring
This commit is contained in:
parent
22b566f916
commit
ff0fbf5810
@ -1,5 +0,0 @@
|
||||
[DEFAULT]
|
||||
test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 OS_TEST_TIMEOUT=60 ${PYTHON:-python} -m subunit.run discover -s fuel_agent/tests -p "*.py" $LISTOPT $IDOPTION
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
||||
test_run_concurrency=echo 1
|
@ -13,10 +13,10 @@
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
from oslotest import base as test_base
|
||||
from oslo.config import cfg
|
||||
import unittest2
|
||||
import zlib
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from fuel_agent import errors
|
||||
from fuel_agent.utils import artifact as au
|
||||
@ -26,7 +26,7 @@ from fuel_agent.utils import utils
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class TestTarget(test_base.BaseTestCase):
|
||||
class TestTarget(unittest2.TestCase):
|
||||
def setUp(self):
|
||||
super(TestTarget, self).setUp()
|
||||
self.tgt = au.Target()
|
||||
@ -50,7 +50,7 @@ class TestTarget(test_base.BaseTestCase):
|
||||
file_handle.flush.assert_called_once_with()
|
||||
|
||||
|
||||
class TestLocalFile(test_base.BaseTestCase):
|
||||
class TestLocalFile(unittest2.TestCase):
|
||||
def setUp(self):
|
||||
super(TestLocalFile, self).setUp()
|
||||
self.lf = au.LocalFile('/dev/null')
|
||||
@ -63,7 +63,7 @@ class TestLocalFile(test_base.BaseTestCase):
|
||||
self.assertRaises(StopIteration, self.lf.next)
|
||||
|
||||
|
||||
class TestHttpUrl(test_base.BaseTestCase):
|
||||
class TestHttpUrl(unittest2.TestCase):
|
||||
@mock.patch.object(utils, 'init_http_request')
|
||||
def test_httpurl_init_ok(self, mock_req):
|
||||
mock_req.return_value = mock.Mock(headers={'content-length': 123})
|
||||
@ -89,7 +89,7 @@ class TestHttpUrl(test_base.BaseTestCase):
|
||||
self.assertEqual(content[data[0]], data[1])
|
||||
|
||||
|
||||
class TestGunzipStream(test_base.BaseTestCase):
|
||||
class TestGunzipStream(unittest2.TestCase):
|
||||
def test_gunzip_stream_next(self):
|
||||
content = ['fake content #1']
|
||||
compressed_stream = [zlib.compress(data) for data in content]
|
||||
@ -98,7 +98,7 @@ class TestGunzipStream(test_base.BaseTestCase):
|
||||
self.assertEqual(content[data[0]], data[1])
|
||||
|
||||
|
||||
class TestChain(test_base.BaseTestCase):
|
||||
class TestChain(unittest2.TestCase):
|
||||
def setUp(self):
|
||||
super(TestChain, self).setUp()
|
||||
self.chain = au.Chain()
|
||||
|
@ -15,10 +15,10 @@
|
||||
import os
|
||||
import shutil
|
||||
import signal
|
||||
import testtools
|
||||
|
||||
import mock
|
||||
from oslo.config import cfg
|
||||
import unittest2
|
||||
|
||||
from fuel_agent import errors
|
||||
from fuel_agent.utils import build as bu
|
||||
@ -29,7 +29,7 @@ from fuel_agent.utils import utils
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class BuildUtilsTestCase(testtools.TestCase):
|
||||
class BuildUtilsTestCase(unittest2.TestCase):
|
||||
|
||||
_fake_ubuntu_release = '''
|
||||
Origin: TestOrigin
|
||||
|
@ -13,13 +13,13 @@
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
from oslotest import base as test_base
|
||||
import unittest2
|
||||
|
||||
from fuel_agent import errors
|
||||
from fuel_agent.objects import configdrive
|
||||
|
||||
|
||||
class TestConfigDriveScheme(test_base.BaseTestCase):
|
||||
class TestConfigDriveScheme(unittest2.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestConfigDriveScheme, self).setUp()
|
||||
|
@ -13,14 +13,14 @@
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
from oslotest import base as test_base
|
||||
import unittest2
|
||||
|
||||
from fuel_agent import errors
|
||||
from fuel_agent.utils import fs as fu
|
||||
from fuel_agent.utils import utils
|
||||
|
||||
|
||||
class TestFSUtils(test_base.BaseTestCase):
|
||||
class TestFSUtils(unittest2.TestCase):
|
||||
|
||||
@mock.patch.object(utils, 'execute')
|
||||
def test_make_fs(self, mock_exec):
|
||||
|
@ -12,21 +12,22 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
from oslotest import base as test_base
|
||||
import six
|
||||
import StringIO
|
||||
|
||||
import mock
|
||||
import six
|
||||
import unittest2
|
||||
|
||||
from fuel_agent import errors
|
||||
from fuel_agent.utils import grub as gu
|
||||
|
||||
if six.PY2:
|
||||
OPEN_FUNCTION_NAME = '__builtin__.open'
|
||||
else:
|
||||
OPEN_FUNCTION_NAME = 'builtins.open'
|
||||
|
||||
from fuel_agent import errors
|
||||
from fuel_agent.utils import grub as gu
|
||||
|
||||
|
||||
class TestGrubUtils(test_base.BaseTestCase):
|
||||
class TestGrubUtils(unittest2.TestCase):
|
||||
|
||||
@mock.patch('fuel_agent.utils.grub.os.path.isdir')
|
||||
def test_guess_grub2_conf(self, mock_isdir):
|
||||
|
@ -13,13 +13,13 @@
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
from oslotest import base as test_base
|
||||
import unittest2
|
||||
|
||||
from fuel_agent.utils import hardware as hu
|
||||
from fuel_agent.utils import utils
|
||||
|
||||
|
||||
class TestHardwareUtils(test_base.BaseTestCase):
|
||||
class TestHardwareUtils(unittest2.TestCase):
|
||||
|
||||
@mock.patch.object(utils, 'execute')
|
||||
def test_parse_dmidecode(self, exec_mock):
|
||||
|
@ -13,13 +13,13 @@
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
from oslotest import base as test_base
|
||||
import unittest2
|
||||
|
||||
from fuel_agent import errors
|
||||
from fuel_agent.objects import image
|
||||
|
||||
|
||||
class TestImage(test_base.BaseTestCase):
|
||||
class TestImage(unittest2.TestCase):
|
||||
|
||||
def test_unsupported_container(self):
|
||||
self.assertRaises(errors.WrongImageDataError, image.Image, 'uri',
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
import copy
|
||||
|
||||
from oslotest import base as test_base
|
||||
import unittest2
|
||||
|
||||
from fuel_agent.drivers import ks_spaces_validator as kssv
|
||||
from fuel_agent import errors
|
||||
@ -182,7 +182,7 @@ SAMPLE_SCHEME = [
|
||||
]
|
||||
|
||||
|
||||
class TestKSSpacesValidator(test_base.BaseTestCase):
|
||||
class TestKSSpacesValidator(unittest2.TestCase):
|
||||
def setUp(self):
|
||||
super(TestKSSpacesValidator, self).setUp()
|
||||
self.fake_scheme = copy.deepcopy(SAMPLE_SCHEME)
|
||||
|
@ -13,14 +13,14 @@
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
from oslotest import base as test_base
|
||||
import unittest2
|
||||
|
||||
from fuel_agent import errors
|
||||
from fuel_agent.utils import lvm as lu
|
||||
from fuel_agent.utils import utils
|
||||
|
||||
|
||||
class TestLvmUtils(test_base.BaseTestCase):
|
||||
class TestLvmUtils(unittest2.TestCase):
|
||||
|
||||
@mock.patch.object(utils, 'execute')
|
||||
def test_pvdisplay(self, mock_exec):
|
||||
|
@ -13,12 +13,12 @@
|
||||
# limitations under the License.
|
||||
|
||||
import copy
|
||||
import mock
|
||||
import os
|
||||
import signal
|
||||
|
||||
import mock
|
||||
from oslo.config import cfg
|
||||
from oslotest import base as test_base
|
||||
import unittest2
|
||||
|
||||
from fuel_agent.drivers import nailgun
|
||||
from fuel_agent import errors
|
||||
@ -37,7 +37,7 @@ from fuel_agent.utils import utils
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class TestManager(test_base.BaseTestCase):
|
||||
class TestManager(unittest2.TestCase):
|
||||
|
||||
@mock.patch('yaml.load')
|
||||
@mock.patch.object(utils, 'init_http_request')
|
||||
@ -547,7 +547,7 @@ none /run/shm tmpfs rw,nosuid,nodev 0 0"""
|
||||
mock_fu.umount_fs.call_args_list)
|
||||
|
||||
|
||||
class TestImageBuild(test_base.BaseTestCase):
|
||||
class TestImageBuild(unittest2.TestCase):
|
||||
|
||||
@mock.patch('yaml.load')
|
||||
@mock.patch.object(utils, 'init_http_request')
|
||||
|
@ -13,8 +13,8 @@
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
from oslotest import base as test_base
|
||||
import six
|
||||
import unittest2
|
||||
|
||||
from fuel_agent import errors
|
||||
from fuel_agent.utils import hardware as hu
|
||||
@ -28,7 +28,7 @@ else:
|
||||
OPEN_FUNCTION_NAME = 'builtins.open'
|
||||
|
||||
|
||||
class TestMdUtils(test_base.BaseTestCase):
|
||||
class TestMdUtils(unittest2.TestCase):
|
||||
|
||||
@mock.patch('fuel_agent.utils.md.utils.execute')
|
||||
def test_mddisplay_nostate_detail(self, mock_exec):
|
||||
|
@ -13,9 +13,9 @@
|
||||
# limitations under the License.
|
||||
|
||||
import copy
|
||||
import mock
|
||||
from oslotest import base as test_base
|
||||
|
||||
import mock
|
||||
import unittest2
|
||||
import yaml
|
||||
|
||||
from fuel_agent.drivers import nailgun
|
||||
@ -579,7 +579,7 @@ MANY_HUGE_DISKS_KS_SPACES = [
|
||||
]
|
||||
|
||||
|
||||
class TestNailgun(test_base.BaseTestCase):
|
||||
class TestNailgun(unittest2.TestCase):
|
||||
|
||||
def test_match_device_by_id_matches(self):
|
||||
# matches by 'by-id' links
|
||||
|
@ -13,7 +13,6 @@
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
|
||||
import unittest2
|
||||
|
||||
from fuel_agent import errors
|
||||
@ -21,7 +20,6 @@ from fuel_agent.objects import partition
|
||||
|
||||
|
||||
class TestMultipleDevice(unittest2.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(self.__class__, self).setUp()
|
||||
self.md = partition.MD(name='name', level='level')
|
||||
@ -76,7 +74,6 @@ class TestMultipleDevice(unittest2.TestCase):
|
||||
|
||||
|
||||
class TestPartition(unittest2.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestPartition, self).setUp()
|
||||
self.pt = partition.Partition('name', 'count', 'device', 'begin',
|
||||
@ -109,7 +106,6 @@ class TestPartition(unittest2.TestCase):
|
||||
|
||||
|
||||
class TestPartitionScheme(unittest2.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestPartitionScheme, self).setUp()
|
||||
self.p_scheme = partition.PartitionScheme()
|
||||
|
@ -12,16 +12,17 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import mock
|
||||
from oslotest import base as test_base
|
||||
import time
|
||||
|
||||
import mock
|
||||
import unittest2
|
||||
|
||||
from fuel_agent import errors
|
||||
from fuel_agent.utils import partition as pu
|
||||
from fuel_agent.utils import utils
|
||||
|
||||
|
||||
class TestPartitionUtils(test_base.BaseTestCase):
|
||||
class TestPartitionUtils(unittest2.TestCase):
|
||||
@mock.patch.object(pu, 'make_label')
|
||||
def test_wipe(self, mock_label):
|
||||
# should run call make_label method
|
||||
|
@ -13,13 +13,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import testtools
|
||||
import socket
|
||||
|
||||
import mock
|
||||
from oslo.config import cfg
|
||||
import requests
|
||||
import socket
|
||||
import stevedore
|
||||
import unittest2
|
||||
import urllib3
|
||||
|
||||
from fuel_agent import errors
|
||||
@ -29,7 +29,7 @@ from fuel_agent.utils import utils
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class ExecuteTestCase(testtools.TestCase):
|
||||
class ExecuteTestCase(unittest2.TestCase):
|
||||
"""This class is partly based on the same class in openstack/ironic."""
|
||||
|
||||
def setUp(self):
|
||||
|
@ -1,9 +1,6 @@
|
||||
hacking>=0.8.0,<0.9
|
||||
mock==1.0.1
|
||||
# TODO(prmtl): remove oslotest and (probably) testools in favor of unittest2
|
||||
oslotest==1.0
|
||||
testtools>=0.9.34
|
||||
unittest2==1.0.1
|
||||
pytest>=2.7.2
|
||||
pytest-cov>=1.8.1
|
||||
requests-mock>=0.6
|
||||
unittest2==1.1.0
|
||||
|
Loading…
Reference in New Issue
Block a user