summaryrefslogtreecommitdiffstats
path: root/dcae-policy/tests/test_discovery.py
diff options
context:
space:
mode:
authorLusheng Ji <lji@research.att.com>2018-04-12 21:42:15 +0000
committerGerrit Code Review <gerrit@onap.org>2018-04-12 21:42:15 +0000
commitfe5179575191dd40af3d9e4a8d4bd0144e4d08de (patch)
treeae096943a244065006fc21b750fb61e6ef00f529 /dcae-policy/tests/test_discovery.py
parent0b36661caa4c32d652614f256b41644ade09a937 (diff)
parent5a412c36b76f375aba863e3668ce6cb4f457e0d7 (diff)
Merge "2.3.0 dcaepolicyplugin and data types"
Diffstat (limited to 'dcae-policy/tests/test_discovery.py')
-rw-r--r--dcae-policy/tests/test_discovery.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/dcae-policy/tests/test_discovery.py b/dcae-policy/tests/test_discovery.py
index 893b7ce..129ad99 100644
--- a/dcae-policy/tests/test_discovery.py
+++ b/dcae-policy/tests/test_discovery.py
@@ -22,6 +22,8 @@ import base64
import json
import pytest
+import requests
+from cloudify.exceptions import NonRecoverableError
from cloudify.state import current_ctx
from dcaepolicyplugin import discovery, tasks
@@ -30,12 +32,12 @@ from tests.mock_cloudify_ctx import MockCloudifyContextFull
from tests.mock_setup import (MONKEYED_POLICY_ID, POLICY_ID, MonkeyedNode,
MonkeyedResponse)
-POLICY_HANDLER_FROM_KV = "http:policy_handler_from_kv:25577"
+POLICY_HANDLER_FROM_KV = "http://policy_handler_from_kv:25577"
def monkeyed_discovery_get_failure(full_path):
"""monkeypatch for the GET to consul"""
- return MonkeyedResponse(full_path)
+ raise requests.ConnectionError("monkey-boom")
def test_discovery_failure(monkeypatch):
@@ -50,8 +52,12 @@ def test_discovery_failure(monkeypatch):
)
try:
current_ctx.set(node_policy.ctx)
- tasks.PolicyHandler._lazy_init()
- assert tasks.PolicyHandler.DEFAULT_URL == tasks.PolicyHandler._url
+ with pytest.raises(NonRecoverableError) as excinfo:
+ tasks.PolicyHandler._lazy_init()
+
+ CtxLogger.log_ctx_info("test_discovery_failure: {0}".format(str(excinfo.value)))
+ assert str(excinfo.value).startswith("ConnectionError")
+
finally:
tasks.PolicyHandler._url = None