Merge "Get rid of testtools and fixtures"
This commit is contained in:
commit
9aeaa29f5d
|
@ -16,11 +16,9 @@
|
|||
import io
|
||||
import json
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import fixtures
|
||||
import testtools
|
||||
|
||||
from metalsmith import _cmd
|
||||
from metalsmith import _instance
|
||||
from metalsmith import _provisioner
|
||||
|
@ -28,17 +26,26 @@ from metalsmith import instance_config
|
|||
from metalsmith import sources
|
||||
|
||||
|
||||
class Base(unittest.TestCase):
|
||||
def setUp(self):
|
||||
super(Base, self).setUp()
|
||||
|
||||
print_fixture = mock.patch(
|
||||
'metalsmith._format._print', autospec=True)
|
||||
self.mock_print = print_fixture.start()
|
||||
self.addCleanup(print_fixture.stop)
|
||||
|
||||
|
||||
@mock.patch.object(_provisioner, 'Provisioner', autospec=True)
|
||||
class TestDeploy(testtools.TestCase):
|
||||
class TestDeploy(Base):
|
||||
def setUp(self):
|
||||
super(TestDeploy, self).setUp()
|
||||
self.print_fixture = self.useFixture(fixtures.MockPatch(
|
||||
'metalsmith._format._print', autospec=True))
|
||||
self.mock_print = self.print_fixture.mock
|
||||
|
||||
self.os_conf_fixture = self.useFixture(fixtures.MockPatchObject(
|
||||
_cmd.os_config, 'OpenStackConfig', autospec=True))
|
||||
self.mock_os_conf = self.os_conf_fixture.mock
|
||||
os_conf_fixture = mock.patch.object(
|
||||
_cmd.os_config, 'OpenStackConfig', autospec=True)
|
||||
self.mock_os_conf = os_conf_fixture.start()
|
||||
self.addCleanup(os_conf_fixture.stop)
|
||||
|
||||
self._init = False
|
||||
|
||||
def _check(self, mock_pr, args, reserve_args, provision_args,
|
||||
|
@ -530,13 +537,7 @@ class TestDeploy(testtools.TestCase):
|
|||
|
||||
@mock.patch.object(_provisioner, 'Provisioner', autospec=True)
|
||||
@mock.patch.object(_cmd.os_config, 'OpenStackConfig', autospec=True)
|
||||
class TestUndeploy(testtools.TestCase):
|
||||
def setUp(self):
|
||||
super(TestUndeploy, self).setUp()
|
||||
self.print_fixture = self.useFixture(fixtures.MockPatch(
|
||||
'metalsmith._format._print', autospec=True))
|
||||
self.mock_print = self.print_fixture.mock
|
||||
|
||||
class TestUndeploy(Base):
|
||||
def test_ok(self, mock_os_conf, mock_pr):
|
||||
node = mock_pr.return_value.unprovision_node.return_value
|
||||
node.id = '123'
|
||||
|
@ -617,12 +618,9 @@ class TestUndeploy(testtools.TestCase):
|
|||
|
||||
@mock.patch.object(_provisioner, 'Provisioner', autospec=True)
|
||||
@mock.patch.object(_cmd.os_config, 'OpenStackConfig', autospec=True)
|
||||
class TestShowWait(testtools.TestCase):
|
||||
class TestShowWait(Base):
|
||||
def setUp(self):
|
||||
super(TestShowWait, self).setUp()
|
||||
self.print_fixture = self.useFixture(fixtures.MockPatch(
|
||||
'metalsmith._format._print', autospec=True))
|
||||
self.mock_print = self.print_fixture.mock
|
||||
self.instances = [
|
||||
mock.Mock(
|
||||
spec=_instance.Instance,
|
||||
|
|
|
@ -14,14 +14,13 @@
|
|||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import testtools
|
||||
|
||||
from metalsmith import instance_config
|
||||
|
||||
|
||||
class TestGenericConfig(testtools.TestCase):
|
||||
class TestGenericConfig(unittest.TestCase):
|
||||
CLASS = instance_config.GenericConfig
|
||||
|
||||
def setUp(self):
|
||||
|
|
|
@ -13,12 +13,11 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import fixtures
|
||||
from openstack import exceptions as os_exc
|
||||
import requests
|
||||
import testtools
|
||||
|
||||
from metalsmith import _instance
|
||||
from metalsmith import _provisioner
|
||||
|
@ -34,7 +33,7 @@ NODE_FIELDS = ['name', 'id', 'instance_info', 'instance_id', 'is_maintenance',
|
|||
'allocation_id']
|
||||
|
||||
|
||||
class TestInit(testtools.TestCase):
|
||||
class TestInit(unittest.TestCase):
|
||||
def test_missing_auth(self):
|
||||
self.assertRaisesRegex(TypeError, 'must be provided',
|
||||
_provisioner.Provisioner)
|
||||
|
@ -58,7 +57,7 @@ class TestInit(testtools.TestCase):
|
|||
mock_conn.assert_called_once_with(config=region)
|
||||
|
||||
|
||||
class Base(testtools.TestCase):
|
||||
class Base(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(Base, self).setUp()
|
||||
|
@ -73,9 +72,11 @@ class Base(testtools.TestCase):
|
|||
self.node.name = 'control-0'
|
||||
|
||||
def _reset_api_mock(self):
|
||||
self.mock_get_node = self.useFixture(
|
||||
fixtures.MockPatchObject(_provisioner.Provisioner, '_get_node',
|
||||
autospec=True)).mock
|
||||
get_node_patcher = mock.patch.object(
|
||||
_provisioner.Provisioner, '_get_node', autospec=True)
|
||||
self.mock_get_node = get_node_patcher.start()
|
||||
self.addCleanup(get_node_patcher.stop)
|
||||
|
||||
self.mock_get_node.side_effect = (
|
||||
lambda self, n, refresh=False: n
|
||||
)
|
||||
|
@ -92,7 +93,7 @@ class Base(testtools.TestCase):
|
|||
self.pr.connection = self.api
|
||||
|
||||
|
||||
class TestGetFindNode(testtools.TestCase):
|
||||
class TestGetFindNode(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestGetFindNode, self).setUp()
|
||||
|
@ -503,10 +504,12 @@ class TestProvisionNode(Base):
|
|||
self.api.network.create_port.return_value.id
|
||||
],
|
||||
}
|
||||
self.configdrive_mock = self.useFixture(
|
||||
fixtures.MockPatchObject(instance_config.GenericConfig,
|
||||
'generate', autospec=True)
|
||||
).mock
|
||||
|
||||
configdrive_patcher = mock.patch.object(
|
||||
instance_config.GenericConfig, 'generate', autospec=True)
|
||||
self.configdrive_mock = configdrive_patcher.start()
|
||||
self.addCleanup(configdrive_patcher.stop)
|
||||
|
||||
self.api.baremetal.get_node.side_effect = lambda _n: self.node
|
||||
self.api.baremetal.get_allocation.side_effect = (
|
||||
lambda _a: self.allocation)
|
||||
|
@ -1934,7 +1937,7 @@ class TestUnprovisionNode(Base):
|
|||
self.assertFalse(self.api.baremetal.update_node.called)
|
||||
|
||||
|
||||
class TestShowInstance(testtools.TestCase):
|
||||
class TestShowInstance(unittest.TestCase):
|
||||
def setUp(self):
|
||||
super(TestShowInstance, self).setUp()
|
||||
self.pr = _provisioner.Provisioner(mock.Mock())
|
||||
|
|
|
@ -13,15 +13,14 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import testtools
|
||||
|
||||
from metalsmith import _scheduler
|
||||
from metalsmith import exceptions
|
||||
|
||||
|
||||
class TestRunFilters(testtools.TestCase):
|
||||
class TestRunFilters(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestRunFilters, self).setUp()
|
||||
|
@ -74,7 +73,7 @@ class TestRunFilters(testtools.TestCase):
|
|||
filters[2].fail.assert_called_once_with()
|
||||
|
||||
|
||||
class TestCapabilitiesFilter(testtools.TestCase):
|
||||
class TestCapabilitiesFilter(unittest.TestCase):
|
||||
|
||||
def test_fail_no_capabilities(self):
|
||||
fltr = _scheduler.CapabilitiesFilter({'profile': 'compute'})
|
||||
|
|
|
@ -13,15 +13,14 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import testtools
|
||||
|
||||
from metalsmith import exceptions
|
||||
from metalsmith import sources
|
||||
|
||||
|
||||
class TestDetect(testtools.TestCase):
|
||||
class TestDetect(unittest.TestCase):
|
||||
|
||||
def test_glance_whole_disk(self):
|
||||
source = sources.detect('foobar')
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import testtools
|
||||
import unittest
|
||||
|
||||
from metalsmith import _utils
|
||||
|
||||
|
||||
class TestIsHostnameSafe(testtools.TestCase):
|
||||
class TestIsHostnameSafe(unittest.TestCase):
|
||||
|
||||
def test_valid(self):
|
||||
self.assertTrue(_utils.is_hostname_safe('spam'))
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
coverage!=4.4,>=4.0 # Apache-2.0
|
||||
doc8>=0.6.0 # Apache-2.0
|
||||
flake8-import-order>=0.13 # LGPLv3
|
||||
fixtures>=3.0.0 # Apache-2.0/BSD
|
||||
hacking>=3.0.0,<3.1.0 # Apache-2.0
|
||||
stestr>=1.0.0 # Apache-2.0
|
||||
testtools>=2.2.0 # MIT
|
||||
Pygments>=2.2.0 # BSD
|
||||
|
|
Loading…
Reference in New Issue