summaryrefslogtreecommitdiffstats
path: root/onap-dcae-dcaepolicy-lib/tests/test_dcae_policy.py
diff options
context:
space:
mode:
authorSchmalzried, Terry (ts862m) <ts862m@att.com>2019-11-25 18:09:53 -0500
committerSchmalzried, Terry (ts862m) <ts862m@att.com>2019-11-26 10:37:13 -0500
commit0095ee39734b4f58ec8fc72fc09d7e3bc167d274 (patch)
treefea94c02ea25005951d7f58d59877bf053ef2896 /onap-dcae-dcaepolicy-lib/tests/test_dcae_policy.py
parent8060697f3634bd21a66347114160ed416a9f617e (diff)
policy lib 3.x support
Issue-ID: DCAEGEN2-1548 Change-Id: Id1c10f08f1375554aa744332bdfe37e1d6afc9d8 Signed-off-by: Schmalzried, Terry (ts862m) <ts862m@att.com>
Diffstat (limited to 'onap-dcae-dcaepolicy-lib/tests/test_dcae_policy.py')
-rw-r--r--onap-dcae-dcaepolicy-lib/tests/test_dcae_policy.py32
1 files changed, 16 insertions, 16 deletions
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={