コード例 #1
0
def test_del_mgmt_iface_1(monkeypatch):
    """Verify that del_mgmt_iface function return correct set of commands and exceptions when mgmt interface can not be deleted.

    """
    comm_expect = ['ip link delete veth19']
    cmd_list = []

    def mockreturn(command):
        cmd_list.append(command)
        rc = "0"
        return "", "", rc
    lh = IpNetworkNamespace(LH_CFG, OPTS)
    monkeypatch.setattr(lh.ssh, 'native_cmd', mockreturn)
    lh.del_mgmt_iface()
    assert comm_expect[0] == cmd_list[0]
コード例 #2
0
def test_del_mgmt_iface_2(monkeypatch):
    """Verify that del_mgmt_iface function return correct set of commands and exceptions when mgmt interface can not be deleted.

    """
    comm_expect = ['ip link delete veth19']
    output_expect = "Failed to delete management iface for HOST.\n"
    cmd_list = []

    def mockreturn(command):
        cmd_list.append(command)
        rc = 5
        return "", "", rc
    lh = IpNetworkNamespace(LH_CFG, OPTS)
    monkeypatch.setattr(lh.ssh, 'native_cmd', mockreturn)
    with pytest.raises(Exception) as excepinfo:
        lh.del_mgmt_iface()
    assert comm_expect[0] == cmd_list[0]
    print(str(excepinfo.value))
    print(output_expect)
    assert output_expect == str(excepinfo.value)