コード例 #1
0
def test_commit_error(device):
    """test commit error with dynamic reply"""

    # bind configuration util
    assert device.bind(cu=Config) == None

    # create error xml
    error = etree.fromstring("""
        <rpc-error xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/14.1R4/junos" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
            <error-type>application</error-type>
            <error-tag>invalid-value</error-tag>
            <error-severity>error</error-severity>
            <error-path>[edit]</error-path>
            <error-message>mgd: Missing mandatory statement: 'test error'</error-message>
            <error-info>
                <bad-element>system</bad-element>
            </error-info>
        </rpc-error>
    """)

    # set CommitError exception as result for rpc commit_configuration
    rpc_reply_dict['commit-configuration'] = CommitError(error)

    # check if CommitError will be raised
    with pytest.raises(CommitError):
        # commit configuration
        device.cu.commit()
コード例 #2
0
def test_commit_error(device):
    """test commit error with dynamic reply"""

    # bind configuration util
    assert device.bind(cu=Config) == None

    # set result for rpc load_config
    rpc_reply_dict[
        "load-configuration"
    ] = """
        <rpc-reply>
            <load-configuration-results>
                <ok/>
            </load-configuration-results>
        </rpc-reply>"""

    # load confgiuratin and check result
    result = device.cu.load("set interfaces ge-0/0/0 disable", format="set")
    assert result.find(".//ok") is not None
コード例 #3
0
def test_bind_to_pyez_dev(device):
    """bind instance of neighbors to device """
    device.bind(neighbors=Neighbors)
    assert device.neighbors.display