summaryrefslogtreecommitdiffstats
path: root/components/pm-subscription-handler
diff options
context:
space:
mode:
authorefiacor <fiachra.corcoran@est.tech>2020-10-13 11:41:41 +0100
committerFiachra Corcoran <fiachra.corcoran@est.tech>2020-10-14 09:30:02 +0000
commit75c997686e5f85709b8c2bfc3f46d9661710a9f8 (patch)
tree3cb4ff54cb47deda7cb75101c09069d6acf64f94 /components/pm-subscription-handler
parent5d9a6fc623fd8f5147f3df7d42947f97a95ded53 (diff)
[PMSH] Bug fix for missing sdnc params in DELETE event
Signed-off-by: efiacor <fiachra.corcoran@est.tech> Change-Id: I051cf6fd727ad99451c3c8386f604501b2eef8e0 Issue-ID: DCAEGEN2-2483
Diffstat (limited to 'components/pm-subscription-handler')
-rwxr-xr-xcomponents/pm-subscription-handler/Changelog.md4
-rwxr-xr-xcomponents/pm-subscription-handler/pmsh_service/mod/api/db_models.py12
-rwxr-xr-xcomponents/pm-subscription-handler/pmsh_service/mod/network_function.py6
-rw-r--r--components/pm-subscription-handler/pom.xml2
-rwxr-xr-xcomponents/pm-subscription-handler/tests/test_network_function.py19
-rw-r--r--components/pm-subscription-handler/version.properties2
6 files changed, 25 insertions, 20 deletions
diff --git a/components/pm-subscription-handler/Changelog.md b/components/pm-subscription-handler/Changelog.md
index 1d97b586..ca988296 100755
--- a/components/pm-subscription-handler/Changelog.md
+++ b/components/pm-subscription-handler/Changelog.md
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
+## [1.1.2]
+### Changed
+* Bug fix for missing sdnc params in DELETE event (DCAEGEN2-2483)
+
## [1.1.1]
### Changed
* Moved to alpine base image (DCAEGEN2-2292)
diff --git a/components/pm-subscription-handler/pmsh_service/mod/api/db_models.py b/components/pm-subscription-handler/pmsh_service/mod/api/db_models.py
index ff172d1c..a8b13e89 100755
--- a/components/pm-subscription-handler/pmsh_service/mod/api/db_models.py
+++ b/components/pm-subscription-handler/pmsh_service/mod/api/db_models.py
@@ -66,8 +66,8 @@ class NetworkFunctionModel(db.Model):
cascade='all, delete-orphan',
backref='nf')
- def __init__(self, nf_name, model_invariant_id, model_version_id, sdnc_model_name=None,
- sdnc_model_version=None):
+ def __init__(self, nf_name, model_invariant_id, model_version_id, sdnc_model_name,
+ sdnc_model_version):
self.nf_name = nf_name
self.model_invariant_id = model_invariant_id
self.model_version_id = model_version_id
@@ -79,11 +79,11 @@ class NetworkFunctionModel(db.Model):
def to_nf(self):
from mod.network_function import NetworkFunction
- return NetworkFunction(**{'nf_name': self.nf_name,
+ return NetworkFunction(sdnc_model_name=self.sdnc_model_name,
+ sdnc_model_version=self.sdnc_model_version,
+ **{'nf_name': self.nf_name,
'model_invariant_id': self.model_invariant_id,
- 'model_version_id': self.model_version_id,
- 'sdnc_model_name': self.sdnc_model_name,
- 'sdnc_model_version': self.sdnc_model_version})
+ 'model_version_id': self.model_version_id})
class NfSubRelationalModel(db.Model):
diff --git a/components/pm-subscription-handler/pmsh_service/mod/network_function.py b/components/pm-subscription-handler/pmsh_service/mod/network_function.py
index fd940385..798da00b 100755
--- a/components/pm-subscription-handler/pmsh_service/mod/network_function.py
+++ b/components/pm-subscription-handler/pmsh_service/mod/network_function.py
@@ -24,13 +24,13 @@ from mod.api.db_models import NetworkFunctionModel
class NetworkFunction:
- def __init__(self, **kwargs):
+ def __init__(self, sdnc_model_name=None, sdnc_model_version=None, **kwargs):
""" Object representation of the NetworkFunction. """
self.nf_name = kwargs.get('nf_name')
self.model_invariant_id = kwargs.get('model_invariant_id')
self.model_version_id = kwargs.get('model_version_id')
- self.sdnc_model_name = None
- self.sdnc_model_version = None
+ self.sdnc_model_name = sdnc_model_name
+ self.sdnc_model_version = sdnc_model_version
@classmethod
def nf_def(cls):
diff --git a/components/pm-subscription-handler/pom.xml b/components/pm-subscription-handler/pom.xml
index 2fa95b88..b28c6737 100644
--- a/components/pm-subscription-handler/pom.xml
+++ b/components/pm-subscription-handler/pom.xml
@@ -32,7 +32,7 @@
<groupId>org.onap.dcaegen2.services</groupId>
<artifactId>pmsh</artifactId>
<name>dcaegen2-services-pm-subscription-handler</name>
- <version>1.1.1-SNAPSHOT</version>
+ <version>1.1.2-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sonar.sources>.</sonar.sources>
diff --git a/components/pm-subscription-handler/tests/test_network_function.py b/components/pm-subscription-handler/tests/test_network_function.py
index f79ec93d..ea5d2c7e 100755
--- a/components/pm-subscription-handler/tests/test_network_function.py
+++ b/components/pm-subscription-handler/tests/test_network_function.py
@@ -17,7 +17,7 @@
# ============LICENSE_END=====================================================
import json
import os
-from unittest.mock import patch
+from unittest.mock import patch, Mock
from mod.network_function import NetworkFunction
from tests.base_setup import BaseClassSetup
@@ -31,12 +31,14 @@ class NetworkFunctionTests(BaseClassSetup):
def setUp(self):
super().setUp()
- self.nf_1 = NetworkFunction(nf_name='pnf_1',
- model_invariant_id='some-id',
- model_version_id='some-id')
- self.nf_2 = NetworkFunction(nf_name='pnf_2',
- model_invariant_id='some-id',
- model_version_id='some-id')
+ self.nf_1 = NetworkFunction(sdnc_model_name='blah', sdnc_model_version=1.0,
+ **{'nf_name': 'pnf_1',
+ 'model_invariant_id': 'some_id',
+ 'model_version_id': 'some_other_id'})
+ self.nf_2 = NetworkFunction(sdnc_model_name='blah', sdnc_model_version=2.0,
+ **{'nf_name': 'pnf_2',
+ 'model_invariant_id': 'some_id',
+ 'model_version_id': 'some_other_id'})
with open(os.path.join(os.path.dirname(__file__), 'data/aai_model_info.json'), 'r') as data:
self.good_model_info = json.loads(data.read())
with open(os.path.join(os.path.dirname(__file__),
@@ -75,9 +77,8 @@ class NetworkFunctionTests(BaseClassSetup):
self.assertEqual(nf, same_nf)
def test_delete_network_function(self):
- sub = self.app_conf.subscription
for nf in [self.nf_1, self.nf_2]:
- sub.add_network_function_to_subscription(nf, self.app_conf.subscription.get())
+ self.app_conf.subscription.add_network_function_to_subscription(nf, Mock())
nfs = NetworkFunction.get_all()
self.assertEqual(2, len(nfs))
NetworkFunction.delete(nf_name=self.nf_1.nf_name)
diff --git a/components/pm-subscription-handler/version.properties b/components/pm-subscription-handler/version.properties
index 9461aa95..e6eb586c 100644
--- a/components/pm-subscription-handler/version.properties
+++ b/components/pm-subscription-handler/version.properties
@@ -1,6 +1,6 @@
major=1
minor=1
-patch=1
+patch=2
base_version=${major}.${minor}.${patch}
release_version=${base_version}
snapshot_version=${base_version}-SNAPSHOT