summaryrefslogtreecommitdiffstats
path: root/components/pm-subscription-handler/tests
diff options
context:
space:
mode:
Diffstat (limited to 'components/pm-subscription-handler/tests')
-rwxr-xr-xcomponents/pm-subscription-handler/tests/data/pm_subscription_event.json2
-rw-r--r--components/pm-subscription-handler/tests/test_policy_response_handler.py48
-rwxr-xr-xcomponents/pm-subscription-handler/tests/test_subscription.py24
3 files changed, 15 insertions, 59 deletions
diff --git a/components/pm-subscription-handler/tests/data/pm_subscription_event.json b/components/pm-subscription-handler/tests/data/pm_subscription_event.json
index a3a6ce3d..cd547d9d 100755
--- a/components/pm-subscription-handler/tests/data/pm_subscription_event.json
+++ b/components/pm-subscription-handler/tests/data/pm_subscription_event.json
@@ -5,7 +5,7 @@
"policyName":"pmsh-operational-policy",
"changeType":"CREATE",
"closedLoopControlName":"pmsh-control-loop",
- "ipAddress": "1.2.3.4",
+ "ipv4Address": "1.2.3.4",
"subscription":{
"subscriptionName":"ExtraPM-All-gNB-R2B",
"administrativeState":"UNLOCKED",
diff --git a/components/pm-subscription-handler/tests/test_policy_response_handler.py b/components/pm-subscription-handler/tests/test_policy_response_handler.py
index e678d839..26a06fce 100644
--- a/components/pm-subscription-handler/tests/test_policy_response_handler.py
+++ b/components/pm-subscription-handler/tests/test_policy_response_handler.py
@@ -1,5 +1,5 @@
# ============LICENSE_START===================================================
-# Copyright (C) 2019-2021 Nordix Foundation.
+# Copyright (C) 2019-2020 Nordix Foundation.
# ============================================================================
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@
from unittest.mock import patch
from mod.api.db_models import SubscriptionModel
-from mod.network_function import NetworkFunction, NetworkFunctionFilter
+from mod.network_function import NetworkFunction
from mod.policy_response_handler import PolicyResponseHandler, policy_response_handle_functions
from mod.subscription import AdministrativeState, SubNfState
from tests.base_setup import BaseClassSetup
@@ -39,20 +39,6 @@ class PolicyResponseHandlerTest(BaseClassSetup):
self.policy_response_handler = PolicyResponseHandler(self.mock_policy_mr_sub,
self.app_conf,
mock_app)
- self.nfFilter = NetworkFunctionFilter(**{
- "nfNames": [
- "^pnf.*"
- ],
- "modelInvariantIDs": [
-
- ],
- "modelVersionIDs": [
-
- ],
- "modelNames": [
-
- ]
- })
def tearDown(self):
super().tearDown()
@@ -68,7 +54,7 @@ class PolicyResponseHandlerTest(BaseClassSetup):
self.policy_response_handler._handle_response(
self.app_conf.subscription.subscriptionName,
AdministrativeState.LOCKED.value,
- self.nf.nf_name, 'success', 'DELETED')
+ self.nf.nf_name, 'success')
mock_delete.assert_called()
@@ -79,7 +65,7 @@ class PolicyResponseHandlerTest(BaseClassSetup):
self.policy_response_handler._handle_response(
self.app_conf.subscription.subscriptionName,
AdministrativeState.LOCKED.value,
- self.nf.nf_name, 'failed','DELETE_FAILED')
+ self.nf.nf_name, 'failed')
mock_update_sub_nf.assert_called_with(
subscription_name=self.app_conf.subscription.subscriptionName,
status=SubNfState.DELETE_FAILED.value, nf_name=self.nf.nf_name)
@@ -91,7 +77,7 @@ class PolicyResponseHandlerTest(BaseClassSetup):
self.policy_response_handler._handle_response(
self.app_conf.subscription.subscriptionName,
AdministrativeState.UNLOCKED.value,
- self.nf.nf_name, 'success', 'CREATED')
+ self.nf.nf_name, 'success')
mock_update_sub_nf.assert_called_with(
subscription_name=self.app_conf.subscription.subscriptionName,
status=SubNfState.CREATED.value, nf_name=self.nf.nf_name)
@@ -103,7 +89,7 @@ class PolicyResponseHandlerTest(BaseClassSetup):
self.policy_response_handler._handle_response(
self.app_conf.subscription.subscriptionName,
AdministrativeState.UNLOCKED.value,
- self.nf.nf_name, 'failed', 'CREATE_FAILED')
+ self.nf.nf_name, 'failed')
mock_update_sub_nf.assert_called_with(
subscription_name=self.app_conf.subscription.subscriptionName,
status=SubNfState.CREATE_FAILED.value, nf_name=self.nf.nf_name)
@@ -116,17 +102,15 @@ class PolicyResponseHandlerTest(BaseClassSetup):
@patch('mod.subscription.Subscription.get')
def test_poll_policy_topic_calls_methods_correct_sub(self, mock_get_sub, mock_handle_response):
response_data = ['{"name": "ResponseEvent","status": { "subscriptionName": '
- '"ExtraPM-All-gNB-R2B", "nfName": "pnf300", "message": "success", "changeType": "CREATED" } }']
+ '"ExtraPM-All-gNB-R2B", "nfName": "pnf300", "message": "success" } }']
self.mock_policy_mr_sub.get_from_topic.return_value = response_data
- mock_get_sub.return_value = \
- SubscriptionModel(subscription_name='ExtraPM-All-gNB-R2B',
- nfFilter=self.nfFilter,
- status=AdministrativeState.UNLOCKED.value)
+ mock_get_sub.return_value = SubscriptionModel(subscription_name='ExtraPM-All-gNB-R2B',
+ status=AdministrativeState.UNLOCKED.value)
self.policy_response_handler.poll_policy_topic()
self.mock_policy_mr_sub.get_from_topic.assert_called()
mock_handle_response.assert_called_with(self.app_conf.subscription.subscriptionName,
AdministrativeState.UNLOCKED.value, 'pnf300',
- 'success', "CREATED")
+ 'success')
@patch('mod.policy_response_handler.PolicyResponseHandler._handle_response')
@patch('mod.subscription.Subscription.get')
@@ -135,10 +119,8 @@ class PolicyResponseHandlerTest(BaseClassSetup):
response_data = ['{"name": "ResponseEvent","status": { "subscriptionName": '
'"Different_Subscription", "nfName": "pnf300", "message": "success" } }']
self.mock_policy_mr_sub.get_from_topic.return_value = response_data
- mock_get_sub.return_value = \
- SubscriptionModel(subscription_name='ExtraPM-All-gNB-R2B',
- nfFilter=self.nfFilter,
- status=AdministrativeState.UNLOCKED.value)
+ mock_get_sub.return_value = SubscriptionModel(subscription_name='ExtraPM-All-gNB-R2B',
+ status=AdministrativeState.UNLOCKED.value)
self.policy_response_handler.poll_policy_topic()
self.mock_policy_mr_sub.get_from_topic.assert_called()
@@ -149,9 +131,7 @@ class PolicyResponseHandlerTest(BaseClassSetup):
@patch('mod.subscription.Subscription.get')
def test_poll_policy_topic_exception(self, mock_get_sub, mock_logger):
self.mock_policy_mr_sub.get_from_topic.return_value = 'wrong_return'
- mock_get_sub.return_value = \
- SubscriptionModel(subscription_name='ExtraPM-All-gNB-R2B',
- nfFilter=self.nfFilter,
- status=AdministrativeState.UNLOCKED.value)
+ mock_get_sub.return_value = SubscriptionModel(subscription_name='ExtraPM-All-gNB-R2B',
+ status=AdministrativeState.UNLOCKED.value)
self.policy_response_handler.poll_policy_topic()
mock_logger.assert_called()
diff --git a/components/pm-subscription-handler/tests/test_subscription.py b/components/pm-subscription-handler/tests/test_subscription.py
index 16c9e509..b18f41e8 100755
--- a/components/pm-subscription-handler/tests/test_subscription.py
+++ b/components/pm-subscription-handler/tests/test_subscription.py
@@ -19,7 +19,6 @@ import json
import os
from unittest.mock import patch, Mock
-from pmsh_service.mod.network_function import NetworkFunctionFilter
from requests import Session
import mod.aai_client as aai_client
@@ -44,9 +43,6 @@ class SubscriptionTest(BaseClassSetup):
mock_session_put.return_value.text = self.aai_response_data
with open(os.path.join(os.path.dirname(__file__), 'data/aai_model_info.json'), 'r') as data:
self.aai_model_data = data.read()
- with open(os.path.join(os.path.dirname(__file__), 'data/cbs_data_1.json'), 'r') as data:
- self.cbs_data = json.load(data)
- self.nfFilter = NetworkFunctionFilter(**self.cbs_data['config']['pmsh_policy']['subscription']['nfFilter'])
mock_session_get.return_value.status_code = 200
mock_session_get.return_value.text = self.aai_model_data
self.mock_mr_sub = Mock()
@@ -160,23 +156,3 @@ class SubscriptionTest(BaseClassSetup):
self.assertEqual(3, len(nfs))
self.assertIsInstance(nfs[0], NetworkFunction)
-
- def test_filter_diff_with_difference(self):
- print(self.nfFilter)
- networkFunction = '{"nfNames":["^pnf.*","^vnf.*"],"modelInvariantIDs": ["Extra Data"],"modelVersionIDs": ["Extra Data"],"modelNames": ["Extra Data""]}'
- self.assertTrue(self.app_conf.subscription._filter_diff(networkFunction));
-
- def test_filter_diff_without_difference(self):
- networkFunction = '{"nfNames":["^pnf.*","^vnf.*"],"modelInvariantIDs": [],"modelVersionIDs": [],"modelNames": []}'
- self.assertTrue(self.app_conf.subscription._filter_diff(networkFunction));
- self.assertIsNotNone(self.app_conf.subscription)
-
- def test_update_subscription_filter(self):
- original_filter = self.app_conf.subscription.nfFilter
- self.app_conf.subscription.nfFilter = '{"nfNames":["^pnf.*","^vnf.*"],"modelInvariantIDs": ["Extra Data"],"modelVersionIDs": ["Extra Data"],"modelNames": ["Extra Data""]}'
- self.app_conf.subscription.update_subscription_filter()
- updated_subscription = (self.app_conf.subscription.get())
- self.assertTrue(updated_subscription.nfFilter == self.app_conf.subscription.nfFilter)
- self.assertFalse(updated_subscription == original_filter)
- print(self.app_conf.subscription.get_network_functions())
-