From 0095ee39734b4f58ec8fc72fc09d7e3bc167d274 Mon Sep 17 00:00:00 2001 From: "Schmalzried, Terry (ts862m)" Date: Mon, 25 Nov 2019 18:09:53 -0500 Subject: policy lib 3.x support Issue-ID: DCAEGEN2-1548 Change-Id: Id1c10f08f1375554aa744332bdfe37e1d6afc9d8 Signed-off-by: Schmalzried, Terry (ts862m) --- onap-dcae-dcaepolicy-lib/tests/test_dcae_policy.py | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'onap-dcae-dcaepolicy-lib/tests') diff --git a/onap-dcae-dcaepolicy-lib/tests/test_dcae_policy.py b/onap-dcae-dcaepolicy-lib/tests/test_dcae_policy.py index 4b3e39c..7281757 100644 --- a/onap-dcae-dcaepolicy-lib/tests/test_dcae_policy.py +++ b/onap-dcae-dcaepolicy-lib/tests/test_dcae_policy.py @@ -1,5 +1,5 @@ # ============LICENSE_START======================================================= -# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved. +# Copyright (c) 2017-2019 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. @@ -132,18 +132,18 @@ class MonkeyedPolicyBody(object): """check whether both policy_body objects are the same""" if not isinstance(policy_body_1, dict) or not isinstance(policy_body_2, dict): return False - for key in policy_body_1.keys(): + for key in policy_body_1: if key not in policy_body_2: return False val_1 = policy_body_1[key] val_2 = policy_body_2[key] + if (val_1 is None) != (val_2 is None): + return False if isinstance(val_1, dict) \ and not MonkeyedPolicyBody.is_the_same_dict(val_1, val_2): return False - if (val_1 is None and val_2 is not None) \ - or (val_1 is not None and val_2 is None) \ - or (val_1 != val_2): + if val_1 != val_2: return False return True @@ -592,7 +592,7 @@ def test_update_policies(): ctx.logger.info("policy[{0}]: not yet in policies".format(MONKEYED_POLICY_ID_M_2)) assert MONKEYED_POLICY_ID_M_2 not in policies - policy_filter_ids = runtime_properties.get(dcae_policy.POLICY_FILTERS, {}).keys() or ["--"] + policy_filter_ids = list(runtime_properties.get(dcae_policy.POLICY_FILTERS) or ["--"]) policy_update(updated_policies=[updated_policy], added_policies={ @@ -653,7 +653,7 @@ def test_update_not_only_config(): ctx.logger.info("policy[{0}]: not yet in policies".format(MONKEYED_POLICY_ID_M_2)) assert MONKEYED_POLICY_ID_M_2 not in policies - policy_filter_ids = runtime_properties.get(dcae_policy.POLICY_FILTERS, {}).keys() or ["--"] + policy_filter_ids = list(runtime_properties.get(dcae_policy.POLICY_FILTERS) or ["--"]) policy_update_not_only_config(updated_policies=[updated_policy], added_policies={ @@ -728,7 +728,7 @@ def test_update_policies_not(): assert unexpected_removed_policy_id not in policies assert junk_policy_filter_id not in runtime_properties.get(dcae_policy.POLICY_FILTERS, {}) - policy_filter_ids = runtime_properties.get(dcae_policy.POLICY_FILTERS, {}).keys() or ["--"] + policy_filter_ids = list(runtime_properties.get(dcae_policy.POLICY_FILTERS) or ["--"]) policy_update(updated_policies=[existing_policy, damaged_policy, updated_policy], added_policies={ @@ -770,7 +770,7 @@ def test_update_many_calcs(): ctx.logger.info("policy[{0}]: not yet in policies".format(MONKEYED_POLICY_ID_M_2)) assert MONKEYED_POLICY_ID_M_2 not in policies - policy_filter_ids = runtime_properties.get(dcae_policy.POLICY_FILTERS, {}).keys() or ["--"] + policy_filter_ids = list(runtime_properties.get(dcae_policy.POLICY_FILTERS) or ["--"]) policy_update_many_calcs(updated_policies=[updated_policy], added_policies={ @@ -823,7 +823,7 @@ def test_remove_all_policies(): policies = runtime_properties[dcae_policy.POLICIES] ctx.logger.info("policies: {0}".format(json.dumps(policies))) - remove_policy_ids = policies.keys() + remove_policy_ids = list(policies) policy_update(updated_policies=None, added_policies=None, removed_policies=remove_policy_ids) @@ -853,7 +853,7 @@ def test_remove_all_policies_twice(): policies = runtime_properties[dcae_policy.POLICIES] ctx.logger.info("policies: {0}".format(json.dumps(policies))) - remove_policy_ids = policies.keys() + remove_policy_ids = list(policies) policy_update(updated_policies=None, added_policies=None, removed_policies=remove_policy_ids) policy_update(updated_policies=None, added_policies=None, removed_policies=remove_policy_ids) @@ -884,7 +884,7 @@ def test_remove_then_update(): policies = runtime_properties[dcae_policy.POLICIES] ctx.logger.info("policies: {0}".format(json.dumps(policies))) - remove_policy_ids = policies.keys() + remove_policy_ids = list(policies) policy_update(updated_policies=None, added_policies=None, removed_policies=remove_policy_ids) updated_policy = MonkeyedPolicyBody.create_policy(MONKEYED_POLICY_ID_2, 2, priority="aa20") @@ -895,7 +895,7 @@ def test_remove_then_update(): ctx.logger.info("policy[{0}]: not yet in policies".format(MONKEYED_POLICY_ID_M_2)) assert MONKEYED_POLICY_ID_M_2 not in policies - policy_filter_ids = runtime_properties.get(dcae_policy.POLICY_FILTERS, {}).keys() or ["--"] + policy_filter_ids = list(runtime_properties.get(dcae_policy.POLICY_FILTERS) or ["--"]) policy_update(updated_policies=[updated_policy], added_policies={ @@ -935,7 +935,7 @@ def test_remove_update_many_calcs(): policies = runtime_properties[dcae_policy.POLICIES] ctx.logger.info("policies: {0}".format(json.dumps(policies))) - remove_policy_ids = policies.keys() + remove_policy_ids = list(policies) policy_update_many_calcs(updated_policies=None, added_policies=None, removed_policies=remove_policy_ids) @@ -952,7 +952,7 @@ def test_remove_update_many_calcs(): ctx.logger.info("policy[{0}]: not yet in policies".format(MONKEYED_POLICY_ID_M_2)) assert MONKEYED_POLICY_ID_M_2 not in policies - policy_filter_ids = runtime_properties.get(dcae_policy.POLICY_FILTERS, {}).keys() or ["--"] + policy_filter_ids = list(runtime_properties.get(dcae_policy.POLICY_FILTERS) or ["--"]) policy_update_many_calcs(updated_policies=[updated_policy], added_policies={ @@ -1004,7 +1004,7 @@ def test_bad_update_many_calcs(): ctx.logger.info("policy[{0}]: not yet in policies".format(MONKEYED_POLICY_ID_M_2)) assert MONKEYED_POLICY_ID_M_2 not in policies - policy_filter_ids = runtime_properties.get(dcae_policy.POLICY_FILTERS, {}).keys() or ["--"] + policy_filter_ids = list(runtime_properties.get(dcae_policy.POLICY_FILTERS) or ["--"]) policy_update_many_calcs(updated_policies=[damaged_policy], added_policies={ -- cgit 1.2.3-korg