コード例 #1
0
ファイル: test_nmcli.py プロジェクト: yadneshk/insights-core
def test_nmcli_dev_show_ab():
    with pytest.raises(SkipException):
        NmcliDevShow(context_wrap(''))

    with pytest.raises(SkipException):
        NmcliDevShow(context_wrap('GENERAL.TYPE: ethernet'))

    with pytest.raises(SkipException):
        NmcliDevShow(context_wrap('Error'))
コード例 #2
0
def test_allnmcli2():
    nmcli_obj1 = NmcliDevShow(context_wrap(NMCLI_SHOW2))
    nmcli_obj2 = NmcliDevShow(context_wrap(NMCLI_SHOW3))
    allnmcli_obj = AllNmcliDevShow(None, [nmcli_obj1, nmcli_obj2])
    con_dev = allnmcli_obj.connected_devices
    assert sorted(con_dev) == sorted(['eth0'])
    assert allnmcli_obj['eth0']['IP4_GATEWAY'] == "10.72.37.254"
    assert allnmcli_obj['eth0']['IP4_DNS1'] == "10.72.17.5"
    assert allnmcli_obj['eth0']['STATE'] == "connected"
    assert allnmcli_obj['eth0'][
        'CON-PATH'] == "/org/freedesktop/NetworkManager/ActiveConnection/1"
    assert len(allnmcli_obj['lo']) == 10
コード例 #3
0
ファイル: test_nmcli.py プロジェクト: smalleni/insights-core
def test_nmcli_doc_examples():
    env = {
        'nmcli_obj': NmcliDevShow(context_wrap(NMCLI_SHOW)),
        'static_conn': NmcliConnShow(context_wrap(STATIC_CONNECTION_SHOW_1)),
    }
    failed, total = doctest.testmod(nmcli, globs=env)
    assert failed == 0
コード例 #4
0
def test_doc_examples():
    env = {
        'allnmclidevshow':
        AllNmcliDevShow(NmcliDevShow(context_wrap(NMCLI_SHOW1)), None),
    }
    failed, total = doctest.testmod(nmcli_dev_show, globs=env)
    assert failed == 0
コード例 #5
0
def test_nmcli():
    nmcli_obj = NmcliDevShow(context_wrap(NMCLI_SHOW))
    con_dev = nmcli_obj.connected_devices
    assert sorted(con_dev) == sorted(['em1', 'em3', 'em2'])
    assert nmcli_obj['em3']['IP4_GATEWAY'] == "10.16.187.254"
    assert nmcli_obj['em3']['IP4_DNS1'] == "10.16.36.29"
    assert nmcli_obj['em3']['IP6_ROUTE1'] == "dst = 2620:52:0:10bb::/64, nh = ::, mt = 100"
    assert nmcli_obj['em1']['STATE'] == "connected"
    assert nmcli_obj['em1']['CON-PATH'] == "--"
    assert nmcli_obj['em3']['IP6_ADDRESS1'] == "2620:52:0:10bb:ba2a:72ff:fede:f8b9/64"
    assert nmcli_obj['em3']['IP6_ADDRESS2'] == "fe80::ba2a:72ff:fede:f8b9/64"
    assert nmcli_obj['em3']['CON-PATH'] == "/org/freedesktop/NetworkManager/ActiveConnection/1"
    assert len(nmcli_obj['em3']) == 17
    assert len(nmcli_obj['em1']) == 7
    nmcli_obj = NmcliDevShow(context_wrap(NMCLI_DEV_SHOW))
    assert 'IP6_GATEWAY' not in nmcli_obj['lo']
    assert 'IP6_ADDRESS1' in nmcli_obj['lo']
    assert nmcli_obj['lo']['IP6_ADDRESS1'] == '::1/128'
    assert nmcli_obj.data is not None