From 1a4e9d90b2e0773e0d5d6f1a6741d40e901fd006 Mon Sep 17 00:00:00 2001 From: Thomas Duval Date: Wed, 29 Nov 2017 08:52:39 +0100 Subject: Fix a bug in unittest Change-Id: I9ef73c7c2f85eb8e72bf34d0095df8bdef86f2a9 --- moonv4/moon_utilities/tests/unit_python/conftest.py | 15 ++++++++++----- moonv4/moon_utilities/tests/unit_python/test_cache.py | 3 +-- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'moonv4/moon_utilities') diff --git a/moonv4/moon_utilities/tests/unit_python/conftest.py b/moonv4/moon_utilities/tests/unit_python/conftest.py index 177a406e..487c2f0e 100644 --- a/moonv4/moon_utilities/tests/unit_python/conftest.py +++ b/moonv4/moon_utilities/tests/unit_python/conftest.py @@ -125,17 +125,19 @@ COMPONENTS = ( "database", "slave", "components/manager", + "components/orchestrator", + "components/interface", ) def get_b64_conf(component=None): - if component in CONF: + if component == "components": + return base64.b64encode( + json.dumps(CONF["components"]).encode('utf-8')+b"\n").decode('utf-8') + elif component in CONF: return base64.b64encode( json.dumps( CONF[component]).encode('utf-8')+b"\n").decode('utf-8') - elif component == "components": - return base64.b64encode( - json.dumps(CONF["components"]).encode('utf-8')+b"\n").decode('utf-8') elif not component: return base64.b64encode( json.dumps(CONF).encode('utf-8')+b"\n").decode('utf-8') @@ -158,7 +160,10 @@ def no_requests(monkeypatch): ) m.register_uri( 'GET', 'http://consul:8500/v1/kv/components?recurse=true', - json=[{'Key': "components", 'Value': get_b64_conf("components")}] + json=[ + {"Key": key, "Value": get_b64_conf(key)} for key in COMPONENTS + ], + # json={'Key': "components", 'Value': get_b64_conf("components")} ) m.register_uri( 'POST', 'http://keystone:5000/v3/auth/tokens', diff --git a/moonv4/moon_utilities/tests/unit_python/test_cache.py b/moonv4/moon_utilities/tests/unit_python/test_cache.py index 5ecacfcf..15c5f22a 100644 --- a/moonv4/moon_utilities/tests/unit_python/test_cache.py +++ b/moonv4/moon_utilities/tests/unit_python/test_cache.py @@ -2,5 +2,4 @@ def test_cache(): from moon_utilities import cache c = cache.Cache() - r = c.authz_requests() - assert isinstance(r, dict) + assert isinstance(c.authz_requests, dict) -- cgit 1.2.3-korg