summaryrefslogtreecommitdiffstats
path: root/dcae-policy/tests/test_discovery.py
diff options
context:
space:
mode:
authorAlex Shatov <alexs@att.com>2018-04-12 17:14:43 -0400
committerAlex Shatov <alexs@att.com>2018-04-12 17:14:43 -0400
commit5a412c36b76f375aba863e3668ce6cb4f457e0d7 (patch)
tree60064e6e2d05bbab383161e17ef4c54d660d772f /dcae-policy/tests/test_discovery.py
parentaf26b8bb3e0145a093f84be270755cc2d475317e (diff)
2.3.0 dcaepolicyplugin and data types
- discovering consul at consul:8500 instead of localhost:8500 - added and refactored unit tests for discovery -- coverage 78% Change-Id: I3712fe36df47d6117206d61ca4916c4dbc42d035 Signed-off-by: Alex Shatov <alexs@att.com> Issue-ID: DCAEGEN2-438
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