Пример #1
0
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]
Пример #2
0
def test_wifi_connect():
    c = DummyDeviceControl()
    ssid = 'ssid'
    password = '******'
    ifname = 'wlan0'
    c.wifi_connect(ssid, password)
    assert c.wifi_connect_args[0] == (ssid, password, None, None)
    c.wifi_connect(ssid, password, ifname)
    assert c.wifi_connect_args[1] == (ssid, password, ifname, None)
    c.wifi_connect(ssid, password, ifname, wait=10)
    assert c.wifi_connect_args[2] == (ssid, password, ifname, 10)
Пример #3
0
def test_wifi_hotspot():
    ifname = 'wlan0'
    con_name = 'MyHotspot'
    ssid = 'ssid'
    band = 'a'
    channel = 123
    password = '******'
    r = Hotspot(ifname, con_name, ssid, password)
    c = DummyDeviceControl(result_wifi_hotspot=r)
    assert c.wifi_hotspot(ifname, con_name, ssid, band, channel, password) == r
    assert c.wifi_hotspot_args == [(ifname, con_name, ssid, band, channel,
                                    password)]
Пример #4
0
def test_show():
    result_show = {'key': 'value'}
    c = DummyDeviceControl(result_show=result_show)
    ifname = 'eth0'
    assert c.show(ifname) == result_show
    assert c.show_args == [ifname]
Пример #5
0
def test_status_when_raise_error():
    c = DummyDeviceControl(raise_error=Exception)
    with pytest.raises(Exception):
        c.status()
Пример #6
0
def test_wifi_rescan_when_raise_error():
    c = DummyDeviceControl(raise_error=Exception)
    with pytest.raises(Exception):
        c.wifi_rescan()
Пример #7
0
def test_delete():
    c = DummyDeviceControl()
    ifname = 'eth0'
    c.delete(ifname)
    assert c.delete_args == [ifname]
Пример #8
0
def test_reapply():
    c = DummyDeviceControl()
    ifname = 'eth0'
    c.reapply(ifname)
    assert c.reapply_args == [ifname]
Пример #9
0
def test_disconnect():
    c = DummyDeviceControl()
    ifname = 'eth0'
    c.disconnect(ifname)
    assert c.disconnect_args[0] == (ifname, None)
Пример #10
0
def test_show_all_when_raise_error():
    c = DummyDeviceControl(raise_error=Exception)
    with pytest.raises(Exception):
        c.show_all()
Пример #11
0
def test_delete_when_raise_error():
    c = DummyDeviceControl(raise_error=Exception)
    with pytest.raises(Exception):
        c.delete('eth0')
Пример #12
0
def test_delete():
    c = DummyDeviceControl()
    ifname = 'eth0'
    c.delete(ifname)
    assert c.delete_args[0] == (ifname, None)
Пример #13
0
def test_wifi_connect():
    c = DummyDeviceControl()
    ssid = 'ssid'
    password = '******'
    c.wifi_connect(ssid, password)
    assert c.wifi_connect_args == [(ssid, password)]
Пример #14
0
def test_wifi():
    result_wifi = [DeviceWifi(False, 'ssid', 'Infra', 1, 54, 78, 'WPA2')]
    c = DummyDeviceControl(result_wifi=result_wifi)
    assert c.wifi() == result_wifi
Пример #15
0
def test_show_when_no_arguments_are_passed():
    c = DummyDeviceControl()
    with pytest.raises(ValueError):
        c.show('eth0')
Пример #16
0
def test_show_all():
    result_show_all = [{'key': 'value'}]
    c = DummyDeviceControl(result_show_all=result_show_all)
    assert c.show_all() == result_show_all
Пример #17
0
def test_wifi_connect_when_raise_error():
    c = DummyDeviceControl(raise_error=Exception)
    ssid = 'ssid'
    password = '******'
    with pytest.raises(Exception):
        c.wifi_connect(ssid, password)
Пример #18
0
def test_call():
    result_call = [Device('eth0', 'ethernet', 'connected,', 'MyNet')]
    c = DummyDeviceControl(result_call)
    assert c() == result_call
Пример #19
0
def test_wifi_hotspot_when_no_arguments_are_passed():
    c = DummyDeviceControl()
    with pytest.raises(ValueError):
        c.wifi_hotspot()
Пример #20
0
def test_disconnect_when_raise_error():
    c = DummyDeviceControl(raise_error=Exception)
    with pytest.raises(Exception):
        c.disconnect('eth0')
Пример #21
0
def test_wifi_rescan():
    c = DummyDeviceControl()
    ifname = 'wlan0'
    ssid = 'ssid'
    c.wifi_rescan(ifname, ssid)
    assert c.wifi_rescan_args == [(ifname, ssid)]
Пример #22
0
def test_reapply_when_raise_error():
    c = DummyDeviceControl(raise_error=Exception)
    with pytest.raises(Exception):
        c.reapply('eth0')
Пример #23
0
def test_disconnect():
    c = DummyDeviceControl()
    ifname = 'eth0'
    c.disconnect(ifname)
    assert c.disconnect_args == [ifname]