fix(vdu): vdu number of instances now is taking into account. Bug 1477
[osm/NBI.git] / osm_nbi / tests / test_pmjobs_topic.py
index d83cc69..84bf048 100644 (file)
@@ -24,8 +24,7 @@ from osm_nbi.engine import EngineException
 from osm_common.dbmemory import DbMemory
 from osm_nbi.pmjobs_topics import PmJobsTopic
 from osm_nbi.tests.test_db_descriptors import db_nsds_text, db_vnfds_text, db_nsrs_text, db_vnfrs_text
-from osm_nbi.tests.pmjob_mocks.response import show_res, cpu_utilization, users, load, empty
-# from osm_nbi.tests.pmjob_mocks.response import prom_res
+from osm_nbi.tests.pmjob_mocks.response import show_res, prom_res, cpu_utilization, users, load, empty
 
 
 class PmJobsTopicTest(asynctest.TestCase):
@@ -62,30 +61,17 @@ class PmJobsTopicTest(asynctest.TestCase):
                 response = yaml.load(empty, Loader=yaml.Loader)
             mock_res.get(endpoint, payload=response)
 
-    def test_get_vnf_metric_list(self):
-        with self.subTest("Test case1 failed in test_get_vnf_metric_list"):
-            metric_list = self.pmjobs_topic._get_vnf_metric_list(self.nsr_id)
-            self.assertCountEqual(metric_list, self.metric_check_list,
-                                  "VNF metric list is not correctly fetched")
-        with self.subTest("Test case2 failed in test_get_vnf_metric_list"):
-            wrong_ns_id = "88d90b0c-faff-4bbc-cccc-aaaaaaaaaaaa"
-            with self.assertRaises(EngineException, msg="ns not found") as e:
-                self.pmjobs_topic._get_vnf_metric_list(wrong_ns_id)
-            self.assertEqual(e.exception.http_code, HTTPStatus.NOT_FOUND, "Wrong HTTP status code")
-            self.assertIn("NS not found with id {}".format(wrong_ns_id),
-                          str(e.exception), "Wrong exception text")
-
-    # async def test_prom_metric_request(self):
-    #     with self.subTest("Test case1 failed in test_prom"):
-    #         prom_response = yaml.load(prom_res, Loader=yaml.Loader)
-    #         with aioresponses() as mock_res:
-    #             self.set_get_mock_res(mock_res, self.nsr_id, self.metric_check_list)
-    #             result = await self.pmjobs_topic._prom_metric_request(self.nsr_id, self.metric_check_list)
-    #         self.assertCountEqual(result, prom_response, "Metric Data is valid")
-    #     with self.subTest("Test case2 failed in test_prom"):
-    #         with self.assertRaises(EngineException, msg="Prometheus not reachable") as e:
-    #             await self.pmjobs_topic._prom_metric_request(self.nsr_id, self.metric_check_list)
-    #         self.assertIn("Connection to ", str(e.exception), "Wrong exception text")
+    async def test_prom_metric_request(self):
+        with self.subTest("Test case1 failed in test_prom"):
+            prom_response = yaml.load(prom_res, Loader=yaml.Loader)
+            with aioresponses() as mock_res:
+                self.set_get_mock_res(mock_res, self.nsr_id, self.metric_check_list)
+                result = await self.pmjobs_topic._prom_metric_request(self.nsr_id, self.metric_check_list)
+            self.assertCountEqual(result, prom_response, "Metric Data is valid")
+        with self.subTest("Test case2 failed in test_prom"):
+            with self.assertRaises(EngineException, msg="Prometheus not reachable") as e:
+                await self.pmjobs_topic._prom_metric_request(self.nsr_id, self.metric_check_list)
+            self.assertIn("Connection to ", str(e.exception), "Wrong exception text")
 
     def test_show(self):
         with self.subTest("Test case1 failed in test_show"):
@@ -93,7 +79,7 @@ class PmJobsTopicTest(asynctest.TestCase):
             with aioresponses() as mock_res:
                 self.set_get_mock_res(mock_res, self.nsr_id, self.metric_check_list)
                 result = self.pmjobs_topic.show(self.session, self.nsr_id)
-            self.assertEqual(len(result['entries']), 3, "Number of metrics returned")
+            self.assertEqual(len(result['entries']), 1, "Number of metrics returned")
             self.assertCountEqual(result, show_response, "Response is valid")
         with self.subTest("Test case2 failed in test_show"):
             wrong_ns_id = "88d90b0c-faff-4bbc-cccc-aaaaaaaaaaaa"