当前位置: 首页>>代码示例>>Python>>正文


Python restconf.ConfdRestTranslator类代码示例

本文整理汇总了Python中rift.restconf.ConfdRestTranslator的典型用法代码示例。如果您正苦于以下问题:Python ConfdRestTranslator类的具体用法?Python ConfdRestTranslator怎么用?Python ConfdRestTranslator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ConfdRestTranslator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_json_body_1

    def test_json_body_1(self):
        self.maxDiff = None
        url = "/api/config/top-list-shallow/"
        body = _collapse_string('''
{
  "top-list-shallow"  :
  [
    {
      "k" : "some key 1"
    },
    {
      "k" : "some key 2"
    }

  ]
}

        ''')

        expected_xml = _collapse_string('''
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"><top-list-shallow xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a" xc:operation="replace"><k xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">some key 1</k></top-list-shallow><top-list-shallow xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a" xc:operation="replace"><k xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">some key 2</k></top-list-shallow></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)
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:30,代码来源:test_rest_put.py

示例2: test_conversion_PUT_JSON_to_XML_list_with_escaped_url

    def test_conversion_PUT_JSON_to_XML_list_with_escaped_url(self):
        self.maxDiff = None

        url = '/api/config/car/subaru%252F1%252F1/models/WRX/'
        json = _collapse_string('''
{
            "models":{
                "name-m":"WRX",
                "year":2015,
                "capacity":5,
                "is-cool":"True"
            }


}
       ''')

        expected_xml = _collapse_string('''
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"><car xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a"><brand>subaru/1/1</brand><models xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a" xc:operation="replace"><name-m xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">WRX</name-m><year xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">2015</year><capacity xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">5</capacity><is-cool xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">true</is-cool></models></car></config>
        ''')

        root = load_schema_root("vehicle-a")

        converter = ConfdRestTranslator(root)

        actual_xml = converter.convert("PUT", url, (json,"application/data+json"))

        self.assertEqual(actual_xml, expected_xml)
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:28,代码来源:test_rest.py

示例3: test_json_body_8

    def test_json_body_8(self):
        self.maxDiff = None
        url = "/api/config/top-container-deep/inner-container"
        body = _collapse_string('''
{
    "a":"another string",
    "inner-list":[
        {
            "k":"another key thing"
        }
    ]
}
        ''')

        expected_xml = _collapse_string('''
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"><top-container-deep xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a"><vehicle-a:inner-container xmlns:vehicle-a="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a"><a xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">another string</a><inner-list xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a" xc:operation="replace"><k xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">another key thing</k></inner-list></vehicle-a:inner-container></top-container-deep></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)
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:25,代码来源:test_rest_put.py

示例4: test_xml_body_3

    def test_xml_body_3(self):
        self.maxDiff = None
        url = "/api/config/top-list-deep"
        body = _collapse_string('''
<top-list-deep>
  <k>some key<k>
  <inner-list>
    <k>some other key</k?
    <a>some string</a>
    <inner-container>
      <a>some other string</a>
    </inner-container>      
  </inner-list>
  <inner-container-shallow>
    <a>yet a third string</a>
  </inner-container-shallow>    
  <inner-container-deep>
    <bottom-list-shallow>
      <k>yet a third key</a>
    </bottom-list-shallow>
  </inner-container-deep>    
</top-list-deep>
        ''')

        expected_xml = _collapse_string('''
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"><top-list-deep xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a" xc:operation="replace"><k>some key<k><inner-list><k>some other key</k?<a>some string</a><inner-container><a>some other string</a></inner-container></inner-list><inner-container-shallow><a>yet a third string</a></inner-container-shallow><inner-container-deep><bottom-list-shallow><k>yet a third key</a></bottom-list-shallow></inner-container-deep></top-list-deep></config>
        ''')

        schema = load_multiple_schema_root(["vehicle-a"])

        converter = ConfdRestTranslator(schema)

        actual_xml = converter.convert("PUT", url, (body,"xml"))

        self.assertEqual(actual_xml, expected_xml)
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:35,代码来源:test_rest_put.py

示例5: test_json_body_2

    def test_json_body_2(self):
        self.maxDiff = None
        url = "/api/config/multi-key"
        body = _collapse_string('''
{
  "multi-key" :
  [
    {
      "foo" : "key part 1",
      "bar" : "key part 2",
      "treasure" : "some string"
    },
    {
      "foo" : "other key part 1",
      "bar" : "other key part 2",
      "treasure" : "some other string"
    }
  ]
}
        ''')

        expected_xml = _collapse_string('''
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"><multi-key xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a" xc:operation="replace"><foo xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">key part 1</foo><bar xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">key part 2</bar><treasure xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">some string</treasure></multi-key><multi-key xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a" xc:operation="replace"><foo xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">other key part 1</foo><bar xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">other key part 2</bar><treasure xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">some other string</treasure></multi-key></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)
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:32,代码来源:test_rest_put.py

示例6: test_json_body_11

    def test_json_body_11(self):
        self.maxDiff = None
        url = "/api/config/misc"
        body = _collapse_string('''
{
    "bool-leaf":true,
    "empty-leaf":[null],
    "enum-leaf":"a",
    "int-leaf":42,
    "list-a":[
        {
            "id":0,
            "foo":"asdf"
        }
    ],
    "list-b":[
        {
            "id":0
        }
    ],
    "numbers":[
        {
            "int8-leaf":0,
            "int16-leaf":0,
            "int32-leaf":0,
            "int64-leaf":0,
            "uint8-leaf":0,
            "uint16-leaf":0,
            "uint32-leaf":0,
            "uint64-leaf":0,
            "decimal-leaf":0
        },
        {
            "int8-leaf":"1",
            "int16-leaf":"0",
            "int32-leaf":"0",
            "int64-leaf":"0",
            "uint8-leaf":"0",
            "uint16-leaf":"0",
            "uint32-leaf":"0",
            "uint64-leaf":"0",
            "decimal-leaf":"0"
        }
    ]
}
        ''')

        expected_xml = _collapse_string('''
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"><vehicle-a:misc xmlns:vehicle-a="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a"><bool-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">true</bool-leaf><empty-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a"></empty-leaf><enum-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">a</enum-leaf><int-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">42</int-leaf><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><list-b 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></list-b><numbers xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a" xc:operation="replace"><int8-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">0</int8-leaf><int16-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">0</int16-leaf><int32-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">0</int32-leaf><int64-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">0</int64-leaf><uint8-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">0</uint8-leaf><uint16-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">0</uint16-leaf><uint32-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">0</uint32-leaf><uint64-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">0</uint64-leaf><decimal-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">0</decimal-leaf></numbers><numbers xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a" xc:operation="replace"><int8-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">1</int8-leaf><int16-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">0</int16-leaf><int32-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">0</int32-leaf><int64-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">0</int64-leaf><uint8-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">0</uint8-leaf><uint16-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">0</uint16-leaf><uint32-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">0</uint32-leaf><uint64-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">0</uint64-leaf><decimal-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">0</decimal-leaf></numbers></vehicle-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)
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:58,代码来源:test_rest_put.py

示例7: test_conversion_PUT_JSON_to_XML_199

    def test_conversion_PUT_JSON_to_XML_199(self):
        self.maxDiff = None

        url = '/api/running/rwrestconf-configuration/log-timing'
        json = _collapse_string('''
{"log-timing" : "True"
}

       ''')

        root = load_schema_root("rw-restconf")

        converter = ConfdRestTranslator(root)

        actual_xml = converter.convert("POST", url, (json,"application/data+json"))
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:15,代码来源:test_rest.py

示例8: test_conversion_CONFD_URL_to_XML_delete_list_key

    def test_conversion_CONFD_URL_to_XML_delete_list_key(self):
        self.maxDiff = None # expected_xml is too large

        url = "/api/operational/top-container-deep/inner-container/inner-list/some-key"
        expected_xml = _collapse_string('''
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"><top-container-deep xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a"><inner-container xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a"><inner-list xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a" xc:operation="delete"><k>some-key</k></inner-list></inner-container></top-container-deep></config>
        ''')

        schema = load_multiple_schema_root(["vehicle-a","vehicle-augment-a"])

        converter = ConfdRestTranslator(schema)

        actual_xml = converter.convert("DELETE", url, None)

        self.assertEquals(actual_xml, expected_xml)
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:15,代码来源:test_rest.py

示例9: test_conversion_CONFD_URL_to_XML_delete_list_key_simple

    def test_conversion_CONFD_URL_to_XML_delete_list_key_simple(self):
        self.maxDiff = None # expected_xml is too large

        url = "/api/operational/car/honda"
        expected_xml = _collapse_string('''
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
  <car xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a" xc:operation="delete">
    <brand>honda</brand>
  </car>
</config>
        ''')

        schema = load_multiple_schema_root(["vehicle-a","vehicle-augment-a"])

        converter = ConfdRestTranslator(schema)

        actual_xml = converter.convert("DELETE", url, None)

        self.assertEquals(actual_xml, expected_xml)
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:19,代码来源:test_rest.py

示例10: test_xml_body_4

    def test_xml_body_4(self):
        self.maxDiff = None
        url = "/api/config/top-list-deep/key1/inner-list/key2"
        body = _collapse_string('''
<inner-list>
  <k>key2</k>
</inner-list>
        ''')

        expected_xml = _collapse_string('''
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"><top-list-deep xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a"><k>key1</k><inner-list xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a" xc:operation="replace"><k>key2</k></inner-list></top-list-deep></config>
        ''')

        schema = load_multiple_schema_root(["vehicle-a"])

        converter = ConfdRestTranslator(schema)

        actual_xml = converter.convert("PUT", url, (body,"xml"))

        self.assertEqual(actual_xml, expected_xml)
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:20,代码来源:test_rest_put.py

示例11: test_json_body_0

    def test_json_body_0(self):
        self.maxDiff = None
        url = "/api/config/top-container-shallow"
        body = _collapse_string('''
{
  "a" : "some leaf 0"
}
        ''')

        expected_xml = _collapse_string('''
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"><vehicle-a:top-container-shallow xmlns:vehicle-a="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a"><a xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a">some leaf 0</a></vehicle-a:top-container-shallow></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)
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:20,代码来源:test_rest_put.py

示例12: test_xml_body_0

    def test_xml_body_0(self):
        self.maxDiff = None
        url = "/api/config/top-container-shallow"
        body = _collapse_string('''
<top-container-shallow>
  <a>some leaf 0</a>
</top-container-shallow>
        ''')

        expected_xml = _collapse_string('''
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"><top-container-shallow xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a" xc:operation="replace"><a>some leaf 0</a></top-container-shallow></config>
        ''')

        schema = load_multiple_schema_root(["vehicle-a"])

        converter = ConfdRestTranslator(schema)

        actual_xml = converter.convert("PUT", url, (body,"xml"))
        
        self.assertEqual(actual_xml, expected_xml)
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:20,代码来源:test_rest_put.py

示例13: test_json_body_serialized_list_element

    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)
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:20,代码来源:test_rest_put.py

示例14: test_json_body_10

    def test_json_body_10(self):
        self.maxDiff = None
        url = "/api/config/misc"
        body = _collapse_string('''
{
        "empty-leaf" : [null]
}
        ''')

        expected_xml = _collapse_string('''
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"><vehicle-a:misc xmlns:vehicle-a="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a"><empty-leaf xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a"></empty-leaf></vehicle-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)
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:20,代码来源:test_rest_put.py

示例15: test_conversion_post_container_list_3

    def test_conversion_post_container_list_3(self):
        self.maxDiff = None # expected_xml is too large

        url = "/api/config/top-container-deep/inner-container"
        expected_xml = _collapse_string('''
<config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0"><top-container-deep xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a"><inner-container xmlns="http://riftio.com/ns/core/mgmt/rwrestconf/test/vehicle-a" xc:operation="create"><a>fdsa</a></inner-container></top-container-deep></config>
        ''')

        body = _collapse_string('''
<inner-container>
  <a>fdsa</a>
</inner-container>
        ''')

        schema = load_multiple_schema_root(["vehicle-a","vehicle-augment-a"])

        converter = ConfdRestTranslator(schema)

        actual_xml = converter.convert("POST", url, (body,"xml"))

        self.assertEquals(actual_xml, expected_xml)
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:21,代码来源:test_rest.py


注:本文中的rift.restconf.ConfdRestTranslator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。