X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_nbi%2Ftests%2Ftest_descriptor_topics.py;h=f6d4001f5d46aa278bb3af58dad7eb2752eb2a90;hb=828f3f29a221f4415e0962e63a491462c1b02370;hp=dcde0a5cfde0dc5109a81e09885c338c1d8de95b;hpb=646773d46821cc2a5461423021e87034a5aa86e9;p=osm%2FNBI.git diff --git a/osm_nbi/tests/test_descriptor_topics.py b/osm_nbi/tests/test_descriptor_topics.py index dcde0a5..f6d4001 100755 --- a/osm_nbi/tests/test_descriptor_topics.py +++ b/osm_nbi/tests/test_descriptor_topics.py @@ -32,6 +32,7 @@ from osm_nbi.tests.test_pkg_descriptors import ( db_nsds_text, vnfd_exploit_text, vnfd_exploit_fixed_text, + db_sfc_nsds_text, ) from osm_nbi.descriptor_topics import VnfdTopic, NsdTopic from osm_nbi.engine import EngineException @@ -2197,6 +2198,61 @@ class Test_NsdTopic(TestCase): "Wrong exception text", ) + def test_validate_vnffgd_descriptor_on_valid_descriptor(self): + indata = yaml.safe_load(db_sfc_nsds_text)[0] + vnffgd = indata.get("vnffgd") + fg = vnffgd[0] + self.topic.validate_vnffgd_data(fg, indata) + + def test_validate_vnffgd_descriptor_not_matching_nfp_position_element(self): + indata = yaml.safe_load(db_sfc_nsds_text)[0] + vnffgd = indata.get("vnffgd") + fg = vnffgd[0] + nfpd = fg.get("nfpd")[0] + with self.assertRaises(EngineException) as e: + fg.update({"nfp-position-element": [{"id": "test1"}]}) + self.topic.validate_vnffgd_data(fg, indata) + self.assertEqual( + e.exception.http_code, + HTTPStatus.UNPROCESSABLE_ENTITY, + "Wrong HTTP status code", + ) + self.assertIn( + norm( + "Error at vnffgd nfpd[id='{}']:nfp-position-element-id='{}' " + "does not match any nfp-position-element".format(nfpd["id"], "test") + ), + norm(str(e.exception)), + "Wrong exception text", + ) + + def test_validate_vnffgd_descriptor_not_matching_constituent_base_element_id( + self, + ): + indata = yaml.safe_load(db_sfc_nsds_text)[0] + vnffgd = indata.get("vnffgd") + fg = vnffgd[0] + fg["nfpd"][0]["position-desc-id"][0]["cp-profile-id"][0][ + "constituent-profile-elements" + ][0]["constituent-base-element-id"] = "error_vnf" + with self.assertRaises(EngineException) as e: + self.topic.validate_vnffgd_data(fg, indata) + self.assertEqual( + e.exception.http_code, + HTTPStatus.UNPROCESSABLE_ENTITY, + "Wrong HTTP status code", + ) + self.assertIn( + norm( + "Error at vnffgd constituent_profile[id='{}']:vnfd-id='{}' " + "does not match any constituent-base-element-id".format( + "vnf1", "error_vnf" + ) + ), + norm(str(e.exception)), + "Wrong exception text", + ) + if __name__ == "__main__": unittest.main()