test_prom_metric_request re-enabled 31/9031/9
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Wed, 3 Jun 2020 13:34:16 +0000 (13:34 +0000)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Wed, 1 Jul 2020 10:22:13 +0000 (10:22 +0000)
Change-Id: I042a29b382949eb1d38083c3818782aa9b552339
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osm_nbi/tests/test_pmjobs_topic.py
tox.ini

index d83cc69..5bcb383 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):
@@ -75,17 +74,17 @@ class PmJobsTopicTest(asynctest.TestCase):
             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"):
diff --git a/tox.ini b/tox.ini
index a847ea1..beb079c 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -25,6 +25,8 @@ install_command = python3 -m pip install -r requirements.txt   -U {opts} {packag
 basepython = python3
 deps =
   nose2
+  nose2-cov
+  coverage
   -rrequirements.txt
   -rtest-requirements.txt
 commands =