LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 0001-Use-mock-for-HTTP-calls-in-unit-tests.patch of Package openstack-mistral (Project home:suse-cloud-ci:rpm-packaging-sles12-Master-a7980f22727f72ad048f236e57222d3b022bf646)

From 02161906bde32d6c7966b8e975097601e21a3dc7 Mon Sep 17 00:00:00 2001
From: Dirk Mueller <dirk@dmllr.de>
Date: Sun, 8 Oct 2017 14:54:46 +0200
Subject: [PATCH] Use mock for HTTP calls in unit tests

In test environment without network access, test_retry_policy_from_var
failed to run as it was not expecting the DNS lookup error. Mocking
the HTTP calls instead helps getting this pass.

Change-Id: I299ecbbc4f3aaafb2044ab32ab3a6bf9d1f9f9b1
---
 mistral/tests/unit/engine/test_policies.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/mistral/tests/unit/engine/test_policies.py b/mistral/tests/unit/engine/test_policies.py
index 650f1ee0..4b018f78 100644
--- a/mistral/tests/unit/engine/test_policies.py
+++ b/mistral/tests/unit/engine/test_policies.py
@@ -557,6 +557,11 @@ class PoliciesTest(base.EngineTestCase):
             task_ex.runtime_context["retry_task_policy"]["retry_no"]
         )
 
+    @mock.patch.object(
+        requests,
+        'request',
+        mock.MagicMock(side_effect=Exception())
+    )
     def test_retry_policy_from_var(self):
         wb_service.create_workbook_v2(RETRY_WB_FROM_VAR)
 
-- 
2.14.1