summaryrefslogtreecommitdiffstats
path: root/components/pm-subscription-handler/tests
diff options
context:
space:
mode:
authorERIMROB <robertas.rimkus@est.tech>2020-06-19 13:09:44 +0100
committerERIMROB <robertas.rimkus@est.tech>2020-06-30 02:15:21 +0100
commitb80449b81a2deb3b6e2510a655de02f9375ef636 (patch)
treeee022a88ee287645c72f6716eb9c501b9cf06484 /components/pm-subscription-handler/tests
parent20637908b156aeff53d7607f88d655d0becc1f11 (diff)
[PMSH] Improve Failure Handling
Signed-off-by: ERIMROB <robertas.rimkus@est.tech> Change-Id: I15d338321957a293e9f444a10cf3bb06f4212f3e Issue-ID: DCAEGEN2-2157
Diffstat (limited to 'components/pm-subscription-handler/tests')
-rw-r--r--components/pm-subscription-handler/tests/test_pmsh_utils.py4
-rw-r--r--components/pm-subscription-handler/tests/test_policy_response_handler.py10
-rwxr-xr-xcomponents/pm-subscription-handler/tests/test_subscription.py4
3 files changed, 6 insertions, 12 deletions
diff --git a/components/pm-subscription-handler/tests/test_pmsh_utils.py b/components/pm-subscription-handler/tests/test_pmsh_utils.py
index cfb78def..1ea27a7c 100644
--- a/components/pm-subscription-handler/tests/test_pmsh_utils.py
+++ b/components/pm-subscription-handler/tests/test_pmsh_utils.py
@@ -137,8 +137,8 @@ class PmshUtilsTestCase(TestCase):
'https://node:30226/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS/'
'dcae_pmsh_cg/1?timeout=1000',
json={"dummy_val": "43c4ee19-6b8d-4279-a80f-c507850aae47"}, status=400)
- mr_topic_data = policy_mr_sub.get_from_topic(1)
- self.assertIsNone(mr_topic_data)
+ with self.assertRaises(Exception):
+ policy_mr_sub.get_from_topic(1)
def test_get_db_connection_url_success(self):
self.env = EnvironmentVarGuard()
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 582f0bc8..9dd73ee0 100644
--- a/components/pm-subscription-handler/tests/test_policy_response_handler.py
+++ b/components/pm-subscription-handler/tests/test_policy_response_handler.py
@@ -20,8 +20,6 @@ import os
from unittest import TestCase
from unittest.mock import patch
-from tenacity import stop_after_attempt
-
from mod.api.db_models import SubscriptionModel
from mod.network_function import NetworkFunction
from mod.pmsh_utils import AppConfig
@@ -128,11 +126,11 @@ class PolicyResponseHandlerTest(TestCase):
mock_handle_response.assert_not_called()
+ @patch('mod.logger.error')
@patch('mod.subscription.Subscription.get')
- def test_poll_policy_topic_exception(self, mock_get_sub):
+ 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',
status=AdministrativeState.UNLOCKED.value)
- self.policy_response_handler.poll_policy_topic.retry.stop = stop_after_attempt(1)
-
- self.assertRaises(Exception, self.policy_response_handler.poll_policy_topic)
+ 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 95db6b24..1543afe8 100755
--- a/components/pm-subscription-handler/tests/test_subscription.py
+++ b/components/pm-subscription-handler/tests/test_subscription.py
@@ -22,7 +22,6 @@ from unittest import TestCase
from unittest.mock import patch
from requests import Session
-from tenacity import stop_after_attempt
import mod.aai_client as aai_client
from mod import db, create_app
@@ -159,7 +158,6 @@ class SubscriptionTest(TestCase):
@patch('mod.subscription.Subscription.update_subscription_status')
def test_process_activate_subscription(self, mock_update_sub_status,
mock_update_sub_nf, mock_add_nfs):
- self.app_conf.subscription.process_subscription.retry.stop = stop_after_attempt(1)
self.app_conf.subscription.process_subscription([list(self.xnfs)[0]], self.mock_mr_pub,
self.app_conf)
@@ -174,7 +172,6 @@ class SubscriptionTest(TestCase):
def test_process_deactivate_subscription(self, mock_update_sub_status,
mock_update_sub_nf):
self.app_conf.subscription.administrativeState = 'LOCKED'
- self.app_conf.subscription.process_subscription.retry.stop = stop_after_attempt(1)
self.app_conf.subscription.process_subscription([list(self.xnfs)[0]], self.mock_mr_pub,
self.app_conf)
@@ -184,7 +181,6 @@ class SubscriptionTest(TestCase):
mock_update_sub_status.assert_called()
def test_process_subscription_exception(self):
- self.app_conf.subscription.process_subscription.retry.stop = stop_after_attempt(1)
self.assertRaises(Exception, self.app_conf.subscription.process_subscription,
[list(self.xnfs)[0]], 'not_mr_pub', 'app_config')