Exemple #1
0
    def test_start_traffic_xml_conversion(self):
        # Open rw-fpath-d yang model
        yang = rw_peas.PeasPlugin('yangmodel_plugin-c', 'YangModelPlugin-1.0')
        yang_model = yang.get_interface('Model')

        #yang_module = yang.get_interface('Module')
        #yang_node = yang.get_interface('Node')
        #yang_key = yang.get_interface('Key')

        model = yang_model.alloc()
        module = yang_model.load_module(model, "rw-fpath-d")

        #populate the start
        self.start.name = "test-name"
        self.start.traffic = RwFpathDYang.StartTraffic_Traffic()
        self.start.traffic.port_name = "riftport"

        # recreate a start using to_xml and from_xml methods
        xml_str = self.start.to_xml(model)
        recreated_start = RwFpathDYang.StartTraffic()
        recreated_start.from_xml(model, xml_str)
        print "Start           : ", self.start
        print "Recreated Start : ", recreated_start

        # check the newly created start is identical
        self.assertEqual(self.start.name, recreated_start.name)
        self.assertEqual(len(self.start.name), len(recreated_start.name))
        self.assertEqual(self.start.traffic.port_name,
                         recreated_start.traffic.port_name)
        self.assertEqual(len(self.start.traffic.port_name),
                         len(recreated_start.traffic.port_name))
Exemple #2
0
    def test_start_traffic_protobuf_conversion(self):
        self.start.name = "test-name"
        self.start.traffic = RwFpathDYang.StartTraffic_Traffic()
        self.start.traffic.port_name = "riftport"

        # recreate a start using to_pbuf and from_pbuf methods
        pbuf = self.start.to_pbuf()
        recreated_start = RwFpathDYang.StartTraffic()
        recreated_start.from_pbuf(pbuf)
        print "Start           : ", self.start
        print "Recreated Start : ", recreated_start

        # check the newly created start is identical
        self.assertEqual(self.start.name, recreated_start.name)
        self.assertEqual(len(self.start.name), len(recreated_start.name))
        self.assertEqual(self.start.traffic.port_name,
                         recreated_start.traffic.port_name)
        self.assertEqual(len(self.start.traffic.port_name),
                         len(recreated_start.traffic.port_name))