Remove NsState from VNF record 49/13349/3
authorPatricia Reinoso <patricia.reinoso@canonical.com>
Tue, 9 May 2023 15:31:26 +0000 (15:31 +0000)
committerPatricia Reinoso <patricia.reinoso@canonical.com>
Wed, 10 May 2023 07:38:39 +0000 (07:38 +0000)
Change-Id: I291b37573f5b6b67daf1f4db416922d70cf019e7
Signed-off-by: Patricia Reinoso <patricia.reinoso@canonical.com>
osm_nbi/instance_topics.py
osm_nbi/tests/test_db_descriptors.py
osm_nbi/tests/test_instance_topics.py
osm_nbi/tests/test_osm_vnfm.py

index c2cd9dd..060e056 100644 (file)
@@ -414,7 +414,7 @@ class NsrTopic(BaseTopic):
         rollback.append({"topic": "nsrs", "_id": nsr_descriptor["id"]})
 
     def _add_vnfr_to_db(self, vnfr_descriptor, rollback, session):
-        self.format_on_new(
+        BaseTopic.format_on_new(
             vnfr_descriptor, session["project_id"], make_public=session["public"]
         )
         self.db.create("vnfrs", vnfr_descriptor)
index 1914190..25817b1 100644 (file)
@@ -471,7 +471,6 @@ db_vnfrs_text = """
 -   _admin:
         created: 1566823354.3668208
         modified: 1566823354.3668208
-        nsState: NOT_INSTANTIATED
         projects_read:
         - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4
         projects_write:
@@ -550,7 +549,6 @@ db_vnfrs_text = """
 -   _admin:
         created: 1566823354.3703845
         modified: 1566823354.3703845
-        nsState: NOT_INSTANTIATED
         projects_read:
         - 25b5aebf-3da1-49ed-99de-1d2b4a86d6e4
         projects_write:
index 0d4adec..96da68c 100644 (file)
@@ -615,6 +615,10 @@ class TestNsrTopic(unittest.TestCase):
                     )
                 else:
                     nsr_id = created_item["nsr-id-ref"]
+                self.assertTrue(
+                    "nsState" not in created_item["_admin"],
+                    "Database VNF record must not contain '_admin.nsState'",
+                )
 
             elif _call[0][0] == "nsrs":
                 created_nsrs.append(created_item)
@@ -624,6 +628,11 @@ class TestNsrTopic(unittest.TestCase):
                     )
                 else:
                     nsr_id = created_item["_id"]
+
+                self.assertTrue(
+                    created_item["_admin"]["nsState"] == "NOT_INSTANTIATED",
+                    "Database record must contain '_admin.nsState=NOT INSTANTIATE'",
+                )
             else:
                 assert True, "created an unknown record {} at database".format(
                     _call[0][0]
@@ -638,10 +647,6 @@ class TestNsrTopic(unittest.TestCase):
                 created_item["_admin"],
                 "Database record must contain '_admin.created'",
             )
-            self.assertTrue(
-                created_item["_admin"]["nsState"] == "NOT_INSTANTIATED",
-                "Database record must contain '_admin.nstate=NOT INSTANTIATE'",
-            )
 
         self.assertEqual(
             len(created_vnfrs), 2, "created a mismatch number of vnfr at database"
index b298828..c3947b9 100644 (file)
@@ -88,10 +88,9 @@ class TestVnfInstances(unittest.TestCase):
         self.assertEqual(
             vnfr_id, vnfr["id"], "Mismatch between return id and database id"
         )
-        self.assertEqual(
-            "NOT_INSTANTIATED",
-            vnfr["_admin"]["nsState"],
-            "Database record must contain 'nsState' NOT_INSTANTIATED",
+        self.assertTrue(
+            "nsState" not in vnfr["_admin"],
+            "Database VNF record must not contain 'nsState'",
         )
         self.assertEqual(
             self.vnfd_id,