summaryrefslogtreecommitdiffstats
path: root/components/pm-subscription-handler/tests/test_policy_response_handler.py
diff options
context:
space:
mode:
Diffstat (limited to 'components/pm-subscription-handler/tests/test_policy_response_handler.py')
-rw-r--r--components/pm-subscription-handler/tests/test_policy_response_handler.py37
1 files changed, 13 insertions, 24 deletions
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 d5ae5ce1..735e9381 100644
--- a/components/pm-subscription-handler/tests/test_policy_response_handler.py
+++ b/components/pm-subscription-handler/tests/test_policy_response_handler.py
@@ -18,32 +18,21 @@
from unittest.mock import patch, MagicMock
from mod import db
+from mod.api.services.measurement_group_service import MgNfState, AdministrativeState
from mod.api.services import measurement_group_service
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, create_subscription_data
class PolicyResponseHandlerTest(BaseClassSetup):
- @classmethod
- def setUpClass(cls):
- super().setUpClass()
@patch('mod.create_app')
def setUp(self, mock_app):
super().setUp()
- super().setUpAppConf()
self.nf = NetworkFunction(nf_name='nf1')
self.policy_response_handler = PolicyResponseHandler(mock_app)
- def tearDown(self):
- super().tearDown()
-
- @classmethod
- def tearDownClass(cls):
- super().tearDownClass()
-
@patch('mod.network_function.NetworkFunction.delete')
def test_handle_response_locked_success(self, mock_delete):
with patch.dict(policy_response_handle_functions,
@@ -64,7 +53,7 @@ class PolicyResponseHandlerTest(BaseClassSetup):
self.nf.nf_name, 'failed')
mock_update_sub_nf.assert_called_with(
measurement_group_name='msr_grp_name',
- status=SubNfState.DELETE_FAILED.value, nf_name=self.nf.nf_name)
+ status=MgNfState.DELETE_FAILED.value, nf_name=self.nf.nf_name)
@patch('mod.network_function.NetworkFunction.delete')
def test_handle_response_locking_success(self, mock_delete):
@@ -86,7 +75,7 @@ class PolicyResponseHandlerTest(BaseClassSetup):
self.nf.nf_name, 'failed')
mock_update_sub_nf.assert_called_with(
measurement_group_name='msr_grp_name',
- status=SubNfState.DELETE_FAILED.value, nf_name=self.nf.nf_name)
+ status=MgNfState.DELETE_FAILED.value, nf_name=self.nf.nf_name)
@patch('mod.api.services.measurement_group_service.update_measurement_group_nf_status')
def test_handle_response_unlocked_success(self, mock_update_sub_nf):
@@ -98,7 +87,7 @@ class PolicyResponseHandlerTest(BaseClassSetup):
self.nf.nf_name, 'success')
mock_update_sub_nf.assert_called_with(
measurement_group_name='msr_grp_name',
- status=SubNfState.CREATED.value, nf_name=self.nf.nf_name)
+ status=MgNfState.CREATED.value, nf_name=self.nf.nf_name)
@patch('mod.api.services.measurement_group_service.update_measurement_group_nf_status')
def test_handle_response_unlocked_success_filtering(self, mock_update_sub_nf):
@@ -107,7 +96,7 @@ class PolicyResponseHandlerTest(BaseClassSetup):
sub = create_subscription_data('sub')
db.session.add(sub)
measurement_group_service.apply_nf_status_to_measurement_group(
- self.nf.nf_name, "MG2", SubNfState.PENDING_CREATE.value)
+ self.nf.nf_name, "MG2", MgNfState.PENDING_CREATE.value)
db.session.commit()
self.policy_response_handler._handle_response(
'MG2',
@@ -115,7 +104,7 @@ class PolicyResponseHandlerTest(BaseClassSetup):
self.nf.nf_name, 'success')
mock_update_sub_nf.assert_called_with(
measurement_group_name='MG2',
- status=SubNfState.CREATED.value, nf_name=self.nf.nf_name)
+ status=MgNfState.CREATED.value, nf_name=self.nf.nf_name)
@patch('mod.api.services.measurement_group_service.update_measurement_group_nf_status')
def test_handle_response_locking_success_filtering(self, mock_update_sub_nf):
@@ -124,7 +113,7 @@ class PolicyResponseHandlerTest(BaseClassSetup):
sub = create_subscription_data('sub')
db.session.add(sub)
measurement_group_service.apply_nf_status_to_measurement_group(
- self.nf.nf_name, "MG2", SubNfState.PENDING_DELETE.value)
+ self.nf.nf_name, "MG2", MgNfState.PENDING_DELETE.value)
db.session.commit()
self.policy_response_handler._handle_response(
'MG2',
@@ -132,7 +121,7 @@ class PolicyResponseHandlerTest(BaseClassSetup):
self.nf.nf_name, 'success')
mock_update_sub_nf.assert_called_with(
measurement_group_name='MG2',
- status=SubNfState.DELETED.value, nf_name=self.nf.nf_name)
+ status=MgNfState.DELETED.value, nf_name=self.nf.nf_name)
@patch('mod.api.services.measurement_group_service.update_measurement_group_nf_status')
def test_handle_response_unlocked_failed(self, mock_update_sub_nf):
@@ -144,7 +133,7 @@ class PolicyResponseHandlerTest(BaseClassSetup):
self.nf.nf_name, 'failed')
mock_update_sub_nf.assert_called_with(
measurement_group_name='msr_grp_name',
- status=SubNfState.CREATE_FAILED.value, nf_name=self.nf.nf_name)
+ status=MgNfState.CREATE_FAILED.value, nf_name=self.nf.nf_name)
@patch('mod.api.services.measurement_group_service.update_measurement_group_nf_status')
def test_handle_response_create_failed_filtering(self, mock_update_sub_nf):
@@ -153,7 +142,7 @@ class PolicyResponseHandlerTest(BaseClassSetup):
sub = create_subscription_data('sub')
db.session.add(sub)
measurement_group_service.apply_nf_status_to_measurement_group(
- self.nf.nf_name, "MG2", SubNfState.PENDING_CREATE.value)
+ self.nf.nf_name, "MG2", MgNfState.PENDING_CREATE.value)
db.session.commit()
self.policy_response_handler._handle_response(
'MG2',
@@ -161,7 +150,7 @@ class PolicyResponseHandlerTest(BaseClassSetup):
self.nf.nf_name, 'failed')
mock_update_sub_nf.assert_called_with(
measurement_group_name='MG2',
- status=SubNfState.CREATE_FAILED.value, nf_name=self.nf.nf_name)
+ status=MgNfState.CREATE_FAILED.value, nf_name=self.nf.nf_name)
@patch('mod.api.services.measurement_group_service.update_measurement_group_nf_status')
def test_handle_response_delete_failed_filtering(self, mock_update_sub_nf):
@@ -170,7 +159,7 @@ class PolicyResponseHandlerTest(BaseClassSetup):
sub = create_subscription_data('sub')
db.session.add(sub)
measurement_group_service.apply_nf_status_to_measurement_group(
- self.nf.nf_name, "MG2", SubNfState.PENDING_DELETE.value)
+ self.nf.nf_name, "MG2", MgNfState.PENDING_DELETE.value)
db.session.commit()
self.policy_response_handler._handle_response(
'MG2',
@@ -178,7 +167,7 @@ class PolicyResponseHandlerTest(BaseClassSetup):
self.nf.nf_name, 'failed')
mock_update_sub_nf.assert_called_with(
measurement_group_name='MG2',
- status=SubNfState.DELETE_FAILED.value, nf_name=self.nf.nf_name)
+ status=MgNfState.DELETE_FAILED.value, nf_name=self.nf.nf_name)
def test_handle_response_exception(self):
self.assertRaises(Exception, self.policy_response_handler._handle_response, 'sub1',