Example #1
0
def test_create_urlfilter_object():
    yrc = Yang2RestConverter()

    netconf_data = """
	      <cmdb xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
            <webfilter>
               <urlfilter mkey="id" nc:operation="create">
                 <id>1</id>
                 <comment></comment>
                 <one-arm-ips-urlfilter>disable</one-arm-ips-urlfilter>
                 <ip-addr-block>disable</ip-addr-block>
                 <entries></entries>
               </urlfilter>
            </webfilter>
          </cmdb>"""

    root = etree.fromstring(netconf_data)

    (url, content, operation) = yrc.extract_url_content_operation(root)

    assert url == "cmdb/webfilter/urlfilter"
    assert content == {'id': '1',
                       'comment': None,
                       'one-arm-ips-urlfilter': 'disable',
                       'ip-addr-block': 'disable',
                       'entries': None}
    assert operation == "create"
Example #2
0
def test_purge_fw_address():
    yrc = Yang2RestConverter()

    netconf_data = """
          <cmdb xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
            <firewall>
               <address nc:operation="delete">
               </address>
            </firewall>
          </cmdb>"""

    root = etree.fromstring(netconf_data)

    (url, content, operation) = yrc.extract_url_content_operation(root)

    assert url == "cmdb/firewall/address/address1"
    assert content == {'id': 'address1'}
    assert operation == "delete"
Example #3
0
def test_get_urlfilter_object():
    yrc = Yang2RestConverter()

    netconf_data = """
	      <cmdb xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
            <webfilter>
               <urlfilter mkey="id">
                 <id>1</id>
               </urlfilter>
            </webfilter>
          </cmdb>"""

    root = etree.fromstring(netconf_data)

    (url, content, operation) = yrc.extract_url_content_operation(root)

    assert url == "cmdb/webfilter/urlfilter/1"
    assert content == {}
    assert operation == None
Example #4
0
def test_edit_urlfilter_object():
    yrc = Yang2RestConverter()

    netconf_data = """
          <cmdb xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
            <webfilter>
               <urlfilter mkey="id" nc:operation="replace">
                 <id>1</id>
                 <comment>New Comment</comment>
               </urlfilter>
            </webfilter>
          </cmdb>"""

    root = etree.fromstring(netconf_data)

    (url, content, operation) = yrc.extract_url_content_operation(root)

    assert url == "cmdb/webfilter/urlfilter/1"
    assert content == {'id': '1', 'comment': 'New Comment'}
    assert operation == "replace"
Example #5
0
def test_delete_urlfilter_child_object():
    yrc = Yang2RestConverter()

    netconf_data = """
          <cmdb xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
            <webfilter>
               <urlfilter mkey="id">
                 <id>1</id>
                 <entries nc:operation="delete" mkey="id">
                        <id>48</id>
                 </entries>
               </urlfilter>
            </webfilter>
          </cmdb>"""

    root = etree.fromstring(netconf_data)

    (url, content, operation) = yrc.extract_url_content_operation(root)

    assert url == "cmdb/webfilter/urlfilter/1/entries/48"
    assert content == {'id': '48'}
    assert operation == "delete"