Merge "Switch from unittest2 to oslotest(testtools)"
This commit is contained in:
commit
4ef60e8164
@ -71,9 +71,11 @@ def setup_db():
|
||||
|
||||
|
||||
def drop_db():
|
||||
global _facade
|
||||
try:
|
||||
engine = get_engine()
|
||||
m.Trigger.metadata.drop_all(engine)
|
||||
_facade = None
|
||||
except Exception as e:
|
||||
LOG.exception("Database shutdown exception: %s", e)
|
||||
return False
|
||||
|
@ -130,10 +130,10 @@ class TestExecutionsController(base.FunctionalTest):
|
||||
@mock.patch.object(engine.EngineClient, 'start_workflow_execution',
|
||||
mock.MagicMock(side_effect=ex.MistralException))
|
||||
def test_post_throws_exception(self):
|
||||
with self.assertRaises(AppError) as context:
|
||||
self.app.post_json('/v1/workbooks/my_workbook/executions',
|
||||
EXECS[0])
|
||||
self.assertIn('Bad response: 400', context.exception.message)
|
||||
context = self.assertRaises(AppError, self.app.post_json,
|
||||
'/v1/workbooks/my_workbook/executions',
|
||||
EXECS[0])
|
||||
self.assertIn('Bad response: 400', context.message)
|
||||
|
||||
@mock.patch.object(db_api, 'execution_delete',
|
||||
mock.MagicMock(return_value=None))
|
||||
|
@ -15,12 +15,14 @@
|
||||
# limitations under the License.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest2
|
||||
import testtools.matchers as ttm
|
||||
|
||||
from oslo import messaging
|
||||
from oslo.config import cfg
|
||||
from oslo.messaging import transport
|
||||
from oslotest import base
|
||||
import pkg_resources as pkg
|
||||
from stevedore import driver
|
||||
|
||||
@ -58,7 +60,7 @@ def get_fake_transport():
|
||||
return transport.Transport(mgr.driver)
|
||||
|
||||
|
||||
class BaseTest(unittest2.TestCase):
|
||||
class BaseTest(base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(BaseTest, self).setUp()
|
||||
|
||||
@ -69,6 +71,20 @@ class BaseTest(unittest2.TestCase):
|
||||
|
||||
# TODO(everyone): add whatever is needed for all Mistral tests in here
|
||||
|
||||
def assertListEqual(self, l1, l2):
|
||||
if tuple(sys.version_info)[0:2] < (2, 7):
|
||||
# for python 2.6 compatibility
|
||||
self.assertEqual(l1, l2)
|
||||
else:
|
||||
super(BaseTest, self).assertListEqual(l1, l2)
|
||||
|
||||
def assertDictEqual(self, cmp1, cmp2):
|
||||
if tuple(sys.version_info)[0:2] < (2, 7):
|
||||
# for python 2.6 compatibility
|
||||
self.assertThat(cmp1, ttm.Equals(cmp2))
|
||||
else:
|
||||
super(BaseTest, self).assertDictEqual(cmp1, cmp2)
|
||||
|
||||
def _assert_single_item(self, items, **props):
|
||||
return self._assert_multiple_items(items, 1, **props)[0]
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
import json
|
||||
import copy
|
||||
|
||||
import unittest2
|
||||
from mistral import exceptions
|
||||
from mistral.openstack.common import log as logging
|
||||
from mistral.actions import action_factory as a_f
|
||||
from mistral.actions import std_actions as std
|
||||
@ -112,9 +112,10 @@ class ActionFactoryTest(base.BaseTest):
|
||||
self.assertEqual(std.SendEmailAction,
|
||||
a_f.get_action_class("std.email"))
|
||||
|
||||
@unittest2.expectedFailure
|
||||
def test_get_action_class_failure(self):
|
||||
self.assertEqual(std.EchoAction, a_f.get_action_class("echo"))
|
||||
exc = self.assertRaises(exceptions.ActionException,
|
||||
a_f.get_action_class, 'echo')
|
||||
self.assertIn('Invalid action name', exc.message)
|
||||
|
||||
def test_create_http_action(self):
|
||||
action = a_f.create_action(DB_TASK)
|
||||
|
@ -15,7 +15,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
import unittest2
|
||||
import testtools
|
||||
from mock import call
|
||||
from mock import patch
|
||||
|
||||
@ -63,12 +63,12 @@ class SendEmailActionTest(base.BaseTest):
|
||||
}
|
||||
self.to_addrs = ', '.join(self.params['to'])
|
||||
|
||||
@unittest2.skipIf(not LOCAL_SMTPD, "Setup local smtpd to run it")
|
||||
@testtools.skipIf(not LOCAL_SMTPD, "Setup local smtpd to run it")
|
||||
def test_send_email_real(self):
|
||||
action = std.SendEmailAction(self.params, self.settings)
|
||||
action.run()
|
||||
|
||||
@unittest2.skipIf(not REMOTE_SMTP, "Configure Remote SMTP to run it")
|
||||
@testtools.skipIf(not REMOTE_SMTP, "Configure Remote SMTP to run it")
|
||||
def test_with_password_real(self):
|
||||
self.params['to'] = ["dz@stackstorm.com"]
|
||||
self.settings = {
|
||||
|
Loading…
Reference in New Issue
Block a user