From 5d3affcceb1ddc231764c4a3769a9911f4f4746c Mon Sep 17 00:00:00 2001 From: Alex Shatov Date: Thu, 1 Feb 2018 14:07:44 -0500 Subject: improved message structure for latest policies * unit test coverage 77% Change-Id: Iebe582bb20173a3f4689239f3a2d822edb48ccc1 Issue-ID: DCAEGEN2-249 Signed-off-by: Alex Shatov --- dcae-policy/LICENSE.txt | 2 +- dcae-policy/dcaepolicyplugin/tasks.py | 3 ++- dcae-policy/tests/test_tasks.py | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dcae-policy/LICENSE.txt b/dcae-policy/LICENSE.txt index cb8008a..f6ead19 100644 --- a/dcae-policy/LICENSE.txt +++ b/dcae-policy/LICENSE.txt @@ -1,7 +1,7 @@ ============LICENSE_START======================================================= org.onap.dcae ================================================================================ -Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. +Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/dcae-policy/dcaepolicyplugin/tasks.py b/dcae-policy/dcaepolicyplugin/tasks.py index fef0850..6d383ce 100644 --- a/dcae-policy/dcaepolicyplugin/tasks.py +++ b/dcae-policy/dcaepolicyplugin/tasks.py @@ -38,6 +38,7 @@ POLICY_REQUIRED = 'policy_required' POLICY_BODY = 'policy_body' POLICIES_FILTERED = 'policies_filtered' POLICY_FILTER = 'policy_filter' +LATEST_POLICIES = "latest_policies" REQUEST_ID = "requestID" @@ -101,7 +102,7 @@ class PolicyHandler(object): return res.raise_for_status() - return res.json() + return res.json().get(LATEST_POLICIES) def _policy_get(): """ diff --git a/dcae-policy/tests/test_tasks.py b/dcae-policy/tests/test_tasks.py index 92d0611..c057137 100644 --- a/dcae-policy/tests/test_tasks.py +++ b/dcae-policy/tests/test_tasks.py @@ -1,7 +1,7 @@ # ============LICENSE_START======================================================= # org.onap.dcae # ================================================================================ -# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved. +# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -38,6 +38,8 @@ POLICY_VERSION = "policyVersion" POLICY_NAME = "policyName" POLICY_BODY = 'policy_body' POLICY_CONFIG = 'config' +LATEST_POLICIES = "latest_policies" + MONKEYED_POLICY_ID = 'monkeyed.Config_peach' LOG_FILE = 'logs/test_dcaepolicyplugin.log' @@ -127,6 +129,7 @@ class MonkeyedResponse(object): self.status_code = 200 self.headers = headers self.resp_json = resp_json + self.text = json.dumps(resp_json or {}) def json(self): """returns json of response""" @@ -229,7 +232,8 @@ def test_policy_get(monkeypatch): def monkeyed_policy_handler_find(full_path, json, headers): """monkeypatch for the GET to policy-engine""" return MonkeyedResponse(full_path, headers, \ - {MONKEYED_POLICY_ID: MonkeyedPolicyBody.create_policy(MONKEYED_POLICY_ID)}) + {LATEST_POLICIES: { + MONKEYED_POLICY_ID: MonkeyedPolicyBody.create_policy(MONKEYED_POLICY_ID)}}) def test_policy_find(monkeypatch): """test policy_get operation on dcae.nodes.policies node""" -- cgit 1.2.3-korg