示例#1
0
def test_device_tv() -> None:
    """Test the Device model with Roku TV."""
    device = models.Device(DEVICE_TV)

    assert device

    assert device.info
    assert isinstance(device.info, models.Info)

    assert device.state
    assert isinstance(device.state, models.State)

    assert device.apps
    assert isinstance(device.apps, List)

    assert device.app
    assert isinstance(device.app, models.Application)
    assert device.app.app_id == "tvinput.dtv"

    assert device.media is None

    assert isinstance(device.channels, List)
    assert len(device.channels) == 2

    assert isinstance(device.channel, models.Channel)
示例#2
0
def test_device() -> None:
    """Test the Device model."""
    device = models.Device(DEVICE)

    assert device

    assert device.info
    assert isinstance(device.info, models.Info)

    assert device.state
    assert isinstance(device.state, models.State)

    assert device.apps
    assert isinstance(device.apps, List)

    assert device.app
    assert isinstance(device.app, models.Application)

    assert device.media
    assert isinstance(device.media, models.MediaState)

    assert isinstance(device.channels, List)
    assert len(device.channels) == 0

    assert device.channel is None
示例#3
0
def test_device_tv_as_dict() -> None:
    """Test the dictionary version of Device."""
    device = models.Device(DEVICE_TV)
    assert device

    device_dict = device.as_dict()
    assert device_dict
    assert isinstance(device_dict, dict)
    assert isinstance(device_dict["info"], dict)
    assert isinstance(device_dict["state"], dict)
    assert isinstance(device_dict["apps"], list)
    assert len(device_dict["apps"]) == 10
    assert device_dict["app"]
    assert isinstance(device_dict["app"], dict)
    assert device_dict["channel"]
    assert isinstance(device_dict["channel"], dict)
    assert device_dict["media"] is None
    assert isinstance(device_dict["channels"], list)
    assert len(device_dict["channels"]) == 2
示例#4
0
def test_device_no_data() -> None:
    """Test the Device model with no device info."""
    with pytest.raises(RokuError):
        models.Device({})