Use mock for a bad HTTP call in unit tests
Depending on the test environment, in test_retry_policy and test_task_defaults_on_error unit tests, the bad URL in the workbook/workflow returned an unexpected response. These are poorly written unit tests as they try to make actual HTTP call to the bad URLs. This patch mocks the HTTP calls instead. Change-Id: Ib155bfe8040f05fe05f9665d3e75f98e205bdd6b Closes-Bug: bug/1641209
This commit is contained in:
parent
f1071f5908
commit
f7501a8716
@ -14,6 +14,7 @@
|
||||
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
import requests
|
||||
|
||||
from mistral.actions import std_actions
|
||||
from mistral.db.v2 import api as db_api
|
||||
@ -512,6 +513,11 @@ class PoliciesTest(base.EngineTestCase):
|
||||
# Need to create a better test.
|
||||
# self.assertEqual(2, task_ex.in_context['wait_after'])
|
||||
|
||||
@mock.patch.object(
|
||||
requests,
|
||||
'request',
|
||||
mock.MagicMock(side_effect=Exception())
|
||||
)
|
||||
def test_retry_policy(self):
|
||||
wb_service.create_workbook_v2(RETRY_WB)
|
||||
|
||||
|
@ -13,7 +13,9 @@
|
||||
# limitations under the License.
|
||||
|
||||
import datetime as dt
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
import requests
|
||||
|
||||
from mistral.db.v2 import api as db_api
|
||||
from mistral.services import scheduler
|
||||
@ -28,6 +30,12 @@ cfg.CONF.set_default('auth_enable', False, group='pecan')
|
||||
|
||||
|
||||
class TaskDefaultsDirectWorkflowEngineTest(base.EngineTestCase):
|
||||
|
||||
@mock.patch.object(
|
||||
requests,
|
||||
'request',
|
||||
mock.MagicMock(side_effect=Exception())
|
||||
)
|
||||
def test_task_defaults_on_error(self):
|
||||
wf_text = """---
|
||||
version: '2.0'
|
||||
|
Loading…
x
Reference in New Issue
Block a user