X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FNBI.git;a=blobdiff_plain;f=osm_nbi%2Ftests%2Ftest_descriptor_topics.py;h=faee74487d79952292dafe48123e850840e0638d;hp=516c1786adf66c6c72fd3a62aba4bdc5305e4653;hb=b995ea260a3a2f88a4e041c7e2dd745daee91825;hpb=3576644cf8903148f59718ff998194b6bee20d84 diff --git a/osm_nbi/tests/test_descriptor_topics.py b/osm_nbi/tests/test_descriptor_topics.py index 516c178..faee744 100755 --- a/osm_nbi/tests/test_descriptor_topics.py +++ b/osm_nbi/tests/test_descriptor_topics.py @@ -116,7 +116,7 @@ class Test_VnfdTopic(TestCase): del test_vnfd["vdu"][0]["cloud-init-file"] del test_vnfd["vnf-configuration"][0]["juju"] try: - self.db.get_one.side_effect = [{"_id": did, "_admin": db_vnfd_content["_admin"]}, None] + self.db.get_one.side_effect = [{"_id": did, "_admin": deepcopy(db_vnfd_content["_admin"])}, None] self.topic.upload_content(fake_session, did, test_vnfd, {}, {"Content-Type": []}) msg_args = self.msg.write.call_args[0] test_vnfd["_id"] = did @@ -130,7 +130,7 @@ class Test_VnfdTopic(TestCase): self.assertEqual(db_args[0], self.topic.topic, "Wrong DB topic") self.assertEqual(db_args[1], did, "Wrong DB VNFD id") admin = db_args[2]["_admin"] - db_admin = db_vnfd_content["_admin"] + db_admin = deepcopy(db_vnfd_content["_admin"]) self.assertEqual(admin["type"], "vnfd", "Wrong descriptor type") self.assertEqual(admin["created"], db_admin["created"], "Wrong creation time") self.assertGreater(admin["modified"], db_admin["created"], "Wrong modification time") @@ -147,7 +147,7 @@ class Test_VnfdTopic(TestCase): test_vnfd["vdu"][0]["cloud-init-file"] = tmp1 test_vnfd["vnf-configuration"][0]["juju"] = tmp2 self.db.get_one.side_effect = lambda table, filter, fail_on_empty=None, fail_on_more=None: \ - {"_id": did, "_admin": db_vnfd_content["_admin"]} + {"_id": did, "_admin": deepcopy(db_vnfd_content["_admin"])} with self.subTest(i=2, t='Check Pyangbind Validation: additional properties'): test_vnfd["extra-property"] = 0 try: @@ -311,7 +311,7 @@ class Test_VnfdTopic(TestCase): test_vnfd['vnf-configuration'][0]['config-primitive'] = tmp with self.subTest(i=15, t='Check Input Validation: everything right'): test_vnfd["id"] = "fake-vnfd-id" - self.db.get_one.side_effect = [{"_id": did, "_admin": db_vnfd_content["_admin"]}, None] + self.db.get_one.side_effect = [{"_id": did, "_admin": deepcopy(db_vnfd_content["_admin"])}, None] rc = self.topic.upload_content(fake_session, did, test_vnfd, {}, {"Content-Type": []}) self.assertTrue(rc, "Input Validation: Unexpected failure") return @@ -323,7 +323,7 @@ class Test_VnfdTopic(TestCase): self.fs.dir_ls.return_value = True with self.subTest(i=1, t='Normal Edition'): now = time() - self.db.get_one.side_effect = [vnfd_content, None] + self.db.get_one.side_effect = [deepcopy(vnfd_content), None] data = {"id": "new-vnfd-id", "product-name": "new-vnfd-name"} self.topic.edit(fake_session, did, data) db_args = self.db.replace.call_args[0] @@ -346,7 +346,7 @@ class Test_VnfdTopic(TestCase): self.assertEqual(db_args[2]["product-name"], data["product-name"], "Wrong VNFD Name") with self.subTest(i=2, t='Conflict on Edit'): data = {"id": "fake-vnfd-id", "product-name": "new-vnfd-name"} - self.db.get_one.side_effect = [vnfd_content, {"_id": str(uuid4()), "id": data["id"]}] + self.db.get_one.side_effect = [deepcopy(vnfd_content), {"_id": str(uuid4()), "id": data["id"]}] with self.assertRaises(EngineException, msg="Accepted existing VNFD ID") as e: self.topic.edit(fake_session, did, data) self.assertEqual(e.exception.http_code, HTTPStatus.CONFLICT, "Wrong HTTP status code") @@ -804,7 +804,7 @@ class Test_NsdTopic(TestCase): self.fs.dir_ls.return_value = True with self.subTest(i=1, t='Normal Edition'): now = time() - self.db.get_one.side_effect = [nsd_content, None] + self.db.get_one.side_effect = [deepcopy(nsd_content), None] self.db.get_list.return_value = [db_vnfd_content] data = {"id": "new-nsd-id", "name": "new-nsd-name"} self.topic.edit(fake_session, did, data) @@ -989,7 +989,7 @@ class Test_NsdTopic(TestCase): nsd_descriptor['df'][0]['vnf-profile'][1]['vnfd-id'] = invalid_vnfd_id with self.assertRaises(EngineException) as e: self.db.get_list.return_value = [] - self.topic.check_conflict_on_edit(fake_session, nsd_descriptor, [], 'id') + nsd_descriptor = self.topic.check_conflict_on_edit(fake_session, nsd_descriptor, [], 'id') self.assertEqual(e.exception.http_code, HTTPStatus.CONFLICT, "Wrong HTTP status code") self.assertIn(norm("Descriptor error at 'vnfd-id'='{}' references a non " "existing vnfd".format(invalid_vnfd_id)),