Ejemplo n.º 1
0
def test_that_iproute2_address(*args):

    # dummy test device
    dv1 = TestDevice()

    out = IpAddress.show(
        input_data=[{"test_dev": [{}]}],
        device_obj={"test_dev": dv1},
    )
    # check if the command was formed
    assert "command" in out[0]["test_dev"].keys()
    assert "result" in out[0]["test_dev"].keys()
    time.sleep(3)
Ejemplo n.º 2
0
def test_that_ip_address_show(capfd):

    dv1 = TestDevice(platform="dentos")
    dv2 = TestDevice(platform="dentos")
    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.show(
            input_data=[{
                # device 1
                "test_dev": [{}],
            }],
            device_obj={"test_dev": dv1},
        ))
    print(out)
    assert "command" in out[0]["test_dev"].keys()
    assert "result" in out[0]["test_dev"].keys()
    # check the rc
    assert out[0]["test_dev"]["rc"] == 0

    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.show(
            input_data=[{
                # device 1
                "test_dev1": [
                    {
                        # command 1
                        "dev": "etpmofxl",
                        "scope": 1302,
                        "prefix": "121.185.149.14",
                        "label": "ohmdtsmy",
                        "options": "aetsaobt",
                    },
                    {
                        # command 2
                        "dev": "cekbcgui",
                        "scope": 2358,
                        "prefix": "188.71.46.56",
                        "label": "idmxryad",
                        "options": "chfjsdnf",
                    },
                ],
            }],
            device_obj={
                "test_dev1": dv1,
                "test_dev2": dv2
            },
        ))
    print(out)
    # check if the command was formed
    assert "command" in out[0]["test_dev1"].keys()
    # check if the result was formed
    assert "result" in out[0]["test_dev1"].keys()
    # check the rc
    assert out[0]["test_dev1"]["rc"] == 0

    loop = asyncio.get_event_loop()
    out = loop.run_until_complete(
        IpAddress.show(
            input_data=[{
                # device 1
                "test_dev1": [{
                    "dev": "etpmofxl",
                    "scope": 1302,
                    "prefix": "121.185.149.14",
                    "label": "ohmdtsmy",
                    "options": "aetsaobt",
                }],
                # device 2
                "test_dev2": [{
                    "dev": "cekbcgui",
                    "scope": 2358,
                    "prefix": "188.71.46.56",
                    "label": "idmxryad",
                    "options": "chfjsdnf",
                }],
            }],
            device_obj={
                "test_dev1": dv1,
                "test_dev2": dv2
            },
        ))
    print(out)
    # check if the command was formed
    assert "command" in out[0]["test_dev1"].keys()
    assert "command" in out[1]["test_dev2"].keys()
    # check if the result was formed
    assert "result" in out[0]["test_dev1"].keys()
    assert "result" in out[1]["test_dev2"].keys()
    # check the rc
    assert out[0]["test_dev1"]["rc"] == 0
    assert out[1]["test_dev2"]["rc"] == 0