summaryrefslogtreecommitdiffstats
path: root/components/pm-subscription-handler
diff options
context:
space:
mode:
authorTony Hansen <tony@att.com>2021-03-16 15:09:58 +0000
committerGerrit Code Review <gerrit@onap.org>2021-03-16 15:09:58 +0000
commit2b571e01e0b8915f4a00cace7a7e39aee1826f37 (patch)
tree7c5876e54494698b894246f07c4c6ab96ef6d5e4 /components/pm-subscription-handler
parent9708556b3c15c67a8a6f6fe2586af73bde23e32e (diff)
parentc359095f9569daf9a7d875153a3872c7cb4baf1b (diff)
Merge "[DCAEGEN-2] Added Junit for nfFilter schema validation"
Diffstat (limited to 'components/pm-subscription-handler')
-rwxr-xr-xcomponents/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py5
-rw-r--r--components/pm-subscription-handler/tests/test_pmsh_utils.py38
2 files changed, 39 insertions, 4 deletions
diff --git a/components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py b/components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py
index 7b91a307..a5fc86e6 100755
--- a/components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py
+++ b/components/pm-subscription-handler/pmsh_service/mod/pmsh_utils.py
@@ -128,10 +128,7 @@ class AppConfig:
sub_data = self.subscription.__dict__
validate(instance=sub_data, schema=self.sub_schema)
nf_filter = sub_data["nfFilter"]
- for filter_name in nf_filter:
- if len(nf_filter[filter_name]) > 0:
- break
- else:
+ if not [filter_name for filter_name, val in nf_filter.items() if len(val) > 0]:
raise ValidationError("At least one filter within nfFilter must not be empty")
logger.debug("Subscription schema is valid.")
diff --git a/components/pm-subscription-handler/tests/test_pmsh_utils.py b/components/pm-subscription-handler/tests/test_pmsh_utils.py
index 1711e013..53d4fe64 100644
--- a/components/pm-subscription-handler/tests/test_pmsh_utils.py
+++ b/components/pm-subscription-handler/tests/test_pmsh_utils.py
@@ -165,6 +165,44 @@ class PmshUtilsTestCase(BaseClassSetup):
with self.assertRaises(ValidationError):
self.app_conf.validate_sub_schema()
+ def test_utils_validate_config_subscription_nfFilter_not_empty(self):
+ self.app_conf.subscription.nfFilter = {
+ "nfNames": [
+
+ ],
+ "modelInvariantIDs": [
+
+ ],
+ "modelVersionIDs": [
+
+ ],
+ "modelNames": [
+
+ ]
+ }
+ with self.assertRaises(ValidationError):
+ self.app_conf.validate_sub_schema()
+
+ @patch('mod.logger.debug')
+ def test_utils_validate_config_subscription_nfFilter_with_empty_property(self, mock_logger):
+ self.app_conf.subscription.nfFilter = {
+ "nfNames": [
+ "^pnf.*",
+ "^vnf.*"
+ ],
+ "modelInvariantIDs": [
+ "7129e420-d396-4efb-af02-6b83499b12f8"
+ ],
+ "modelVersionIDs": [
+
+ ],
+ "modelNames": [
+ "pnf102"
+ ]
+ }
+ self.app_conf.validate_sub_schema()
+ mock_logger.assert_called_with("Subscription schema is valid.")
+
def test_utils_validate_config_subscription_where_measurementTypes_is_empty(self):
self.app_conf.subscription.measurementGroups = [{
"measurementGroup": {