From 75c997686e5f85709b8c2bfc3f46d9661710a9f8 Mon Sep 17 00:00:00 2001 From: efiacor Date: Tue, 13 Oct 2020 11:41:41 +0100 Subject: [PMSH] Bug fix for missing sdnc params in DELETE event Signed-off-by: efiacor Change-Id: I051cf6fd727ad99451c3c8386f604501b2eef8e0 Issue-ID: DCAEGEN2-2483 --- components/pm-subscription-handler/Changelog.md | 4 ++++ .../pmsh_service/mod/api/db_models.py | 12 ++++++------ .../pmsh_service/mod/network_function.py | 6 +++--- components/pm-subscription-handler/pom.xml | 2 +- .../tests/test_network_function.py | 19 ++++++++++--------- components/pm-subscription-handler/version.properties | 2 +- 6 files changed, 25 insertions(+), 20 deletions(-) (limited to 'components/pm-subscription-handler') 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 @@ org.onap.dcaegen2.services pmsh dcaegen2-services-pm-subscription-handler - 1.1.1-SNAPSHOT + 1.1.2-SNAPSHOT UTF-8 . 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 -- cgit 1.2.3-korg