コード例 #1
0
def test_device_wifi_parse():
    d1 = '*       AP1  Infra  1     130 Mbit/s  82      ______  WPA1 WPA2'
    assert DeviceWifi.parse(d1) == \
        DeviceWifi(True, 'AP1', 'Infra', 1, 130, 82, 'WPA1 WPA2')
    d2 = '        AP1  Infra  1     130 Mbit/s  82      ______  WPA1 WPA2'
    assert DeviceWifi.parse(d2) == \
        DeviceWifi(False, 'AP1', 'Infra', 1, 130, 82, 'WPA1 WPA2')
コード例 #2
0
def test_device_wifi_parse_include_bssid_line():
    d1 = '*       00:00:00:00:00:00  AP1  Infra  1     130 Mbit/s  82      ______  WPA1 WPA2'
    assert DeviceWifi.parse_include_bssid_line(d1) == \
        DeviceWifi(True, 'AP1', 'Infra', 1, 130, 82, 'WPA1 WPA2')
    d2 = '        00:00:00:00:00:00  AP1  Infra  1     130 Mbit/s  82      ______  WPA1 WPA2'
    assert DeviceWifi.parse_include_bssid_line(d2) == \
        DeviceWifi(False, 'AP1', 'Infra', 1, 130, 82, 'WPA1 WPA2')
コード例 #3
0
ファイル: test_device.py プロジェクト: jekir/nmcli
def test_device_wifi():
    s = DummySystemCommand(
        '''IN-USE  SSID             MODE   CHAN  RATE        SIGNAL  BARS  SECURITY
*       AP1  Infra  1     130 Mbit/s  82      ______  WPA1 WPA2
        AP2  Infra  11    195 Mbit/s  74      ______  WPA2
        AP3  Infra  11    195 Mbit/s  72      ______  WPA1 WPA2''')
    device = DeviceControl(s)
    r = device.wifi()
    assert len(r) == 3
    assert r == [
        DeviceWifi(True, 'AP1', 'Infra', 1, 130, 82, 'WPA1 WPA2'),
        DeviceWifi(False, 'AP2', 'Infra', 11, 195, 74, 'WPA2'),
        DeviceWifi(False, 'AP3', 'Infra', 11, 195, 72, 'WPA1 WPA2'),
    ]
    assert s.passed_parameters == ['device', 'wifi']
コード例 #4
0
ファイル: test_device.py プロジェクト: jekir/nmcli
def test_device_wifi_to_json():
    in_use = True
    ssid = 'AP1'
    mode = 'Infra'
    chan = 1
    rate = 130
    signal = 10
    security = 'WPA1'
    d = DeviceWifi(in_use, ssid, mode, chan, rate, signal, security)
    assert d.to_json() == {
        'in_use': in_use,
        'ssid': ssid,
        'mode': mode,
        'chan': chan,
        'rate': rate,
        'signal': signal,
        'security': security
    }
コード例 #5
0
ファイル: test_device.py プロジェクト: ushiboy/nmcli
def test_wifi():
    result_wifi = [
        DeviceWifi(False, 'ssid', '00:00:00:00:00:00', 'Infra', 1, 2400, 54,
                   78, 'WPA2')
    ]
    c = DummyDeviceControl(result_wifi=result_wifi)
    assert c.wifi() == result_wifi
    ifname = 'wlan0'
    assert c.wifi(ifname) == result_wifi
    assert c.wifi_args == [ifname]
コード例 #6
0
ファイル: test_device.py プロジェクト: whattheserver/nmcli
def test_device_wifi():
    d = '''*:AP1:Infra:1:130 Mbit/s:82:WPA1 WPA2
 :AP2:Infra:11:195 Mbit/s:74:WPA2
 :AP3:Infra:11:195 Mbit/s:72:WPA1 WPA2'''
    s = DummySystemCommand(d)
    device = DeviceControl(s)
    r = device.wifi()
    assert len(r) == 3
    assert r == [
        DeviceWifi(True, 'AP1', 'Infra', 1, 130, 82, 'WPA1 WPA2'),
        DeviceWifi(False, 'AP2', 'Infra', 11, 195, 74, 'WPA2'),
        DeviceWifi(False, 'AP3', 'Infra', 11, 195, 72, 'WPA1 WPA2'),
    ]
    assert s.passed_parameters == ['-t', '-f', 'IN-USE,SSID,MODE,CHAN,RATE,SIGNAL,SECURITY',
                                   'device', 'wifi']

    with open(device_wifi_data_file) as f:
        buf = f.read()
    device = DeviceControl(DummySystemCommand(buf))
    r = device.wifi()
    assert len(r) == 3
    assert r == [
        DeviceWifi(False, 'AP1', 'Infra', 11, 195, 72, 'WPA1 WPA2'),
        DeviceWifi(False, 'AP2', 'Infra', 4, 130, 40, 'WPA1 WPA2'),
        DeviceWifi(False, 'AP3', 'Infra', 6, 65, 24, 'WPA2'),
    ]
コード例 #7
0
ファイル: test_device.py プロジェクト: whattheserver/nmcli
def test_device_wifi_parse():
    d1 = '*:AP1:Infra:1:130 Mbit/s:82:WPA1 WPA2'
    assert DeviceWifi.parse(d1) == \
        DeviceWifi(True, 'AP1', 'Infra', 1, 130, 82, 'WPA1 WPA2')
    d2 = ' :AP1:Infra:1:130 Mbit/s:82:WPA1 WPA2'
    assert DeviceWifi.parse(d2) == \
        DeviceWifi(False, 'AP1', 'Infra', 1, 130, 82, 'WPA1 WPA2')
    d3 = ' :AP 1:Infra:1:130 Mbit/s:82:WPA1 WPA2'
    assert DeviceWifi.parse(d3) == \
        DeviceWifi(False, 'AP 1', 'Infra', 1, 130, 82, 'WPA1 WPA2')
    d4 = ' :AAAAAA BBBBBBBBB CCC 9999:Infra:1:130 Mbit/s:82:WPA1 WPA2'
    assert DeviceWifi.parse(d4) == \
        DeviceWifi(False, 'AAAAAA BBBBBBBBB CCC 9999',
                   'Infra', 1, 130, 82, 'WPA1 WPA2')
コード例 #8
0
ファイル: test_device.py プロジェクト: ushiboy/nmcli
def test_device_wifi_parse():
    d1 = '*:AP1:00\\:00\\:00\\:00\\:00\\:00:Infra:1:2400 MHz:130 Mbit/s:82:WPA1 WPA2'
    assert DeviceWifi.parse(d1) == \
        DeviceWifi(True, 'AP1', '00:00:00:00:00:00',
                   'Infra', 1, 2400, 130, 82, 'WPA1 WPA2')
    d2 = ' :AP1:00\\:00\\:00\\:00\\:00\\:01:Infra:1:2401 MHz:130 Mbit/s:82:WPA1 WPA2'
    assert DeviceWifi.parse(d2) == \
        DeviceWifi(False, 'AP1', '00:00:00:00:00:01',
                   'Infra', 1, 2401, 130, 82, 'WPA1 WPA2')
    d3 = ' :AP 1:00\\:00\\:00\\:00\\:00\\:02:Infra:1:2402 MHz:130 Mbit/s:82:WPA1 WPA2'
    assert DeviceWifi.parse(d3) == \
        DeviceWifi(False, 'AP 1', '00:00:00:00:00:02',
                   'Infra', 1, 2402, 130, 82, 'WPA1 WPA2')
    d4 = ' :AAAAAA BBBBBBBBB CCC 9999:00\\:00\\:00\\:00\\:00\\:03:Infra:1:2403 MHz:130 Mbit/s:82:WPA1 WPA2'
    assert DeviceWifi.parse(d4) == \
        DeviceWifi(False, 'AAAAAA BBBBBBBBB CCC 9999', '00:00:00:00:00:03',
                   'Infra', 1, 2403, 130, 82, 'WPA1 WPA2')
コード例 #9
0
ファイル: test_device.py プロジェクト: ryanteck/nmcli
def test_device_wifi():
    d = '''IN-USE  SSID             MODE   CHAN  RATE        SIGNAL  BARS  SECURITY
*       AP1  Infra  1     130 Mbit/s  82      ______  WPA1 WPA2
        AP2  Infra  11    195 Mbit/s  74      ______  WPA2
        AP3  Infra  11    195 Mbit/s  72      ______  WPA1 WPA2'''
    s = DummySystemCommand(d)
    device = DeviceControl(s)
    r = device.wifi()
    assert len(r) == 3
    assert r == [
        DeviceWifi(True, 'AP1', 'Infra', 1, 130, 82, 'WPA1 WPA2'),
        DeviceWifi(False, 'AP2', 'Infra', 11, 195, 74, 'WPA2'),
        DeviceWifi(False, 'AP3', 'Infra', 11, 195, 72, 'WPA1 WPA2'),
    ]
    assert s.passed_parameters == ['device', 'wifi']

    with open(device_wifi_data_file) as f:
        buf = f.read()
    device = DeviceControl(DummySystemCommand(buf))
    r = device.wifi()
    assert len(r) == 3
    assert r == [
        DeviceWifi(False, 'AP1', 'Infra', 11, 195, 72, 'WPA1 WPA2'),
        DeviceWifi(False, 'AP2', 'Infra', 4, 130, 40, 'WPA1 WPA2'),
        DeviceWifi(False, 'AP3', 'Infra', 6, 65, 24, 'WPA2'),
    ]

    with open(device_wifi_data_include_bssid_file) as f:
        buf = f.read()
    device = DeviceControl(DummySystemCommand(buf))
    r = device.wifi()
    assert len(r) == 3
    assert r == [
        DeviceWifi(False, 'AP1', 'Infra', 11, 195, 72, 'WPA1 WPA2'),
        DeviceWifi(False, 'AP2', 'Infra', 4, 130, 40, 'WPA1 WPA2'),
        DeviceWifi(False, 'AP3', 'Infra', 6, 65, 24, 'WPA2'),
    ]
コード例 #10
0
def test_device_wifi():
    d = '''*:AP1:00\\:00\\:00\\:00\\:00\\:00:Infra:1:2400 MHz:130 Mbit/s:82:WPA1 WPA2
 :AP2:00\\:00\\:00\\:00\\:00\\:01:Infra:11:2401 MHz:195 Mbit/s:74:WPA2
 :AP3:00\\:00\\:00\\:00\\:00\\:02:Infra:11:2402 MHz:195 Mbit/s:72:WPA1 WPA2'''
    s = DummySystemCommand(d)
    device = DeviceControl(s)
    r = device.wifi()
    assert len(r) == 3
    assert r == [
        DeviceWifi(True, 'AP1', '00:00:00:00:00:00',
                   'Infra', 1, 2400, 130, 82, 'WPA1 WPA2'),
        DeviceWifi(False, 'AP2', '00:00:00:00:00:01',
                   'Infra', 11, 2401, 195, 74, 'WPA2'),
        DeviceWifi(False, 'AP3', '00:00:00:00:00:02',
                   'Infra', 11, 2402, 195, 72, 'WPA1 WPA2'),
    ]
    assert s.passed_parameters == ['-t', '-f',
                                   'IN-USE,SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,SECURITY',
                                   'device', 'wifi', 'list']

    with open(device_wifi_data_file, encoding='utf-8') as f:
        buf = f.read()
    s2 = DummySystemCommand(buf)
    device = DeviceControl(s2)
    ifname = 'wlan0'
    r = device.wifi(ifname)
    assert len(r) == 3
    assert r == [
        DeviceWifi(False, '', '00:00:00:00:00:00', 'Infra',
                   11, 2400, 195, 72, 'WPA1 WPA2'),
        DeviceWifi(False, 'AP1', '00:00:00:00:00:01',
                   'Infra', 4, 2401, 130, 40, 'WPA1 WPA2'),
        DeviceWifi(False, 'AP2', '00:00:00:00:00:02',
                   'Infra', 6, 2402, 65, 24, 'WPA2'),
    ]
    assert s2.passed_parameters == ['-t', '-f',
                                    'IN-USE,SSID,BSSID,MODE,CHAN,FREQ,RATE,SIGNAL,SECURITY',
                                    'device', 'wifi', 'list', 'ifname', ifname]
コード例 #11
0
ファイル: test_device.py プロジェクト: jekir/nmcli
def test_wifi():
    result_wifi = [DeviceWifi(False, 'ssid', 'Infra', 1, 54, 78, 'WPA2')]
    c = DummyDeviceControl(result_wifi=result_wifi)
    assert c.wifi() == result_wifi
コード例 #12
0
ファイル: test_device.py プロジェクト: ushiboy/nmcli
def test_device_wifi_parse_when_failed():
    d = '*:AP1:Infra:1:130 Mbit/s:82:WPA1 WPA2'
    with pytest.raises(ValueError) as e:
        DeviceWifi.parse(d)
    assert str(e.value) == f'Parse failed [{d}]'