Esempio n. 1
0
def test_get_devices_none_found(hdhomerun_lib):
    from libhdhomerun.api import get_devices
    from libhdhomerun.exceptions import NoDeviceError
    hdhomerun_lib.hdhomerun_discover_find_devices_custom.return_value = 0

    with pytest.raises(NoDeviceError):
        devices = get_devices()
        assert devices == 0
Esempio n. 2
0
def test_get_devices_error(discover_device_mock, hdhomerun_lib):
    from libhdhomerun.api import get_devices
    from libhdhomerun.exceptions import HomeRunError
    hdhomerun_lib.hdhomerun_discover_find_devices_custom.return_value = -1

    with pytest.raises(HomeRunError):
        devices = get_devices()
        assert devices == -1
Esempio n. 3
0
def test_get_devices(hdhomerun_lib, discover_device_mock):
    from libhdhomerun.api import get_devices
    hdhomerun_lib.hdhomerun_discover_find_devices_custom.return_value = 1
    hdhomerun_lib.hdhomerun_discover_device_t.__mul__.return_value = mock.Mock(return_value=[discover_device_mock])

    devices = get_devices()

    assert hdhomerun_lib.hdhomerun_discover_find_devices_custom.call_count == 2  # Device __init__ calls it once, too
    assert len(devices) == 1
    assert devices[0]._id == 0x12345
    assert devices[0]._ip == 2130706433