summaryrefslogtreecommitdiffstats
path: root/components/pm-subscription-handler/tests/test_subscription.py
diff options
context:
space:
mode:
Diffstat (limited to 'components/pm-subscription-handler/tests/test_subscription.py')
-rw-r--r--components/pm-subscription-handler/tests/test_subscription.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/components/pm-subscription-handler/tests/test_subscription.py b/components/pm-subscription-handler/tests/test_subscription.py
new file mode 100644
index 00000000..cbf930fd
--- /dev/null
+++ b/components/pm-subscription-handler/tests/test_subscription.py
@@ -0,0 +1,43 @@
+# ============LICENSE_START===================================================
+# Copyright (C) 2019 Nordix Foundation.
+# ============================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=====================================================
+import json
+import os
+import unittest
+
+from mod.subscription import Subscription, XnfFilter
+
+
+class SubscriptionTestCase(unittest.TestCase):
+
+ def setUp(self):
+ with open(os.path.join(os.path.dirname(__file__), 'data/cbs_data.json'), 'r') as data:
+ self.cbs_data = json.load(data)
+ self.sub = Subscription(**self.cbs_data['policy']['subscription'])
+ self.xnf_filter = XnfFilter(**self.sub.nfFilter)
+
+ def test_xnf_filter_true(self):
+ self.assertTrue(self.xnf_filter.is_xnf_in_filter('pnf1'))
+
+ def test_xnf_filter_false(self):
+ self.assertFalse(self.xnf_filter.is_xnf_in_filter('PNF-33'))
+
+ def test_sub_measurement_group(self):
+ self.assertEqual(len(self.sub.measurementGroups), 2)
+
+ def test_sub_file_location(self):
+ self.assertEqual(self.sub.fileLocation, '/pm/pm.xml')