def test_conversion_url_to_dts_xpath(self): self.maxDiff = None url = "/api/operational/car/toyota/models" expected = "" schema = load_multiple_schema_root(["vehicle-a", "vehicle-augment-a"]) actual = create_dts_xpath_from_url(url, schema) xpath = "D,/vehicle-a:car[vehicle-a:key_name = 'toyota']" value = RwKeyspec.path_from_xpath(VehicleAYang.get_schema(), actual, RwKeyspec.RwXpathType.KEYSPEC, None)
def test_json_body_serialized_list_element(self): self.maxDiff = None url = "/api/config/misc/list-a/0" model = RwYang.model_create_libncx() model.load_schema_ypbc(VehicleAYang.get_schema()) list_a_msg = VehicleAYang.YangData_VehicleA_Misc_ListA(id=0, foo="asdf") list_a_json = list_a_msg.to_json(model) body = _collapse_string(list_a_json) expected_xml = _collapse_string(''' <config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"><misc xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a"><list-a xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a" xc:operation="replace"><id xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">0</id><foo xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">asdf</foo></list-a></misc></config> ''') schema = load_multiple_schema_root(["vehicle-a"]) converter = ConfdRestTranslator(schema) actual_xml = converter.convert("PUT", url, (body, "json")) self.compare_doms(actual_xml, expected_xml)