Exemple #1
0
def test_Header():
    def cleanse(json):
        if 'messageId' in json:
            json['messageId'] = 'TOKEN'
        return json

    expected = {
        "namespace": "Alexa.CameraStreamController",
        "name": "Response",
        "payloadVersion": "3",
        "messageId": "5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
        "correlationToken": "dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg=="
    }

    a = ASHO.Header(
        namespace='Alexa.CameraStreamController',
        name='Response',
        messageId="5f8a426e-01e4-4cc9-8b79-65f8bd0fd8a4",
        correlationToken='dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==',
        payloadVersion='3')
    a.validate()
    assert a.as_dict() == expected

    a = ASHO.Header().from_json(json.dumps(expected))
    a.validate()
    assert a.as_dict() == expected
Exemple #2
0
def test_Namespace():
    expected = 'Alexa.BrightnessController'
    a = ASHO.Namespace('Alexa.BrightnessController')
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.Namespace('Alexa.NewController')
Exemple #3
0
def test_Name():
    expected = 'Response'
    a = ASHO.Name('Response')
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.Name('NotAResponse')
Exemple #4
0
def test_Muted():
    expected = False
    a = ASHO.Muted(False)
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.Muted('Off')
Exemple #5
0
def test_MessageId():
    expected = '123-456'
    a = ASHO.MessageId('123-456')
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.MessageId('123|456')
Exemple #6
0
def test_Message():
    expected = 'A message'
    a = ASHO.Message('A message')
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.Message(0)
Exemple #7
0
def test_Input():
    expected = 'CD'
    a = ASHO.Input('CD')
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.Input(0)
Exemple #8
0
def test_IdleTimeoutSeconds():
    expected = 60
    a = ASHO.IdleTimeoutSeconds(60)
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.IdleTimeoutSeconds('60')
Exemple #9
0
def test_LClockstate():
    expected = 'JAMMED'
    a = ASHO.LClockState('JAMMED')
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.LClockState('OPEN')
Exemple #10
0
def test_Hue():
    expected = .5
    a = ASHO.Hue(.5)
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.Hue(2000)
Exemple #11
0
def test_Number():
    expected = '504'
    a = ASHO.Number('504')
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.Number(504)
Exemple #12
0
def test_PCpercentage():
    expected = 67
    a = ASHO.PCpercentage(67)
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.PCpercentage(102)
Exemple #13
0
def test_Width():
    expected = 1080
    a = ASHO.Height(1080)
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.Height('1080')
Exemple #14
0
def test_PLCpowerLevel():
    expected = 50
    a = ASHO.PLCpowerLevel(50)
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.PLCpowerLevel(102)
Exemple #15
0
def test_VideoCodec():
    expected = 'MPEG2'
    a = ASHO.VideoCodec('MPEG2')
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.VideoCodec('MPEG1000')
Exemple #16
0
def test_TCthermostatMode():
    expected = 'CUSTOM'
    a = ASHO.TCthermostatMode('CUSTOM')
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.TCthermostatMode('HOT')
Exemple #17
0
def test_Temperature():
    expected = {'scale': 'CELSIUS', 'value': 25.3}
    a = ASHO.Temperature(scale='CELSIUS', value=25.3)
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.Temperature(scale='Chilly', value=25.3)
Exemple #18
0
def test_Scale():
    expected = 'KELVIN'
    a = ASHO.Scale('KELVIN')
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.Scale('CHILLY')
Exemple #19
0
def test_Scope():
    expected = {'type': 'BearerToken', 'token': 'Atoken'}
    a = ASHO.Scope(type='BearerToken', token='Atoken')
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.Scope(type='NotaBearerToken', token='Atoken')
Exemple #20
0
def test_Resolution():
    expected = {'width': 1920, 'height': 1080}
    a = ASHO.Resolution(width=1920, height=1080)
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.Resolution(width='1920')
Exemple #21
0
def test_Saturation():
    expected = 0.385
    a = ASHO.Saturation(0.385)
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.Saturation(2)
Exemple #22
0
def test_Protocol():
    expected = 'RTSP'
    a = ASHO.Protocol('RTSP')
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.Protocol('MPEG2')
Exemple #23
0
def test_PayloadVersion():
    expected = '3'
    a = ASHO.PayloadVersion('3')
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.PayloadVersion('2')
Exemple #24
0
def test_PCpowerState():
    expected = 'ON'
    a = ASHO.PCpowerState('ON')
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.PCpowerState(True)
Exemple #25
0
def test_Volume():
    expected = 100
    a = ASHO.Volume(100)
    a.validate()
    assert a.as_dict() == expected

    expected = 0
    a = ASHO.Volume(0)
    a.validate()
    assert a.as_dict() == expected

    with pytest.raises(ValidationError) as e_info:
        a = ASHO.Volume(101)
        a = ASHO.Volume(-1)
Exemple #26
0
def test_CameraStream():
    expected = {
        "protocol": "RTSP",
        "resolution": {
            "width": 1920,
            "height": 1080
        },
        "authorizationType": "BASIC",
        "videoCodec": "H264",
        "audioCodec": "G711",
        "uri": 'http://some/uri'
    }

    a = ASHO.CameraStream(resolution=ASHO.Resolution(width=1920, height=1080),
                          protocol=ASHO.Protocol('RTSP'),
                          authorizationType=ASHO.AuthorizationType('BASIC'),
                          videoCodec=ASHO.VideoCodec('H264'),
                          audioCodec=ASHO.AudioCodec('G711'),
                          uri=ASHO.Uri('http://some/uri'))
    a.validate()
    assert a.as_dict() == expected

    a = ASHO.CameraStream().from_json(json.dumps(expected))
    a.validate()
    assert a.as_dict() == expected
Exemple #27
0
def test_Endpoint():
    expected = {
        "endpointId": "appliance-001",
        "scope": {
            "type": "BearerToken",
            "token": "access-token-from-skill"
        },
        "cookie": {}
    }

    a = ASHO.Endpoint(endpointId='appliance-001',
                      scope=ASHO.Scope(type='BearerToken',
                                       token='access-token-from-skill'),
                      cookie={})
    assert a.as_dict() == expected
Exemple #28
0
def test_Channel():
    expected = {
        'number': '504',
        'callSign': 'NBC4',
        'affiliateCallSign': 'NBC'
    }
    a = ASHO.Channel(number='504', callSign='NBC4', affiliateCallSign='NBC')
    a.validate()
    assert a.as_dict() == expected
Exemple #29
0
def test_Cause():
    expected = {'type': 'PHYSICAL_INTERACTION'}
    a = ASHO.Cause(type='PHYSICAL_INTERACTION')
    a.validate()
    assert a.as_dict() == expected
Exemple #30
0
def test_CallSign():
    expected = 'NBC4'
    a = ASHO.CallSign('NBC4')
    a.validate()
    assert a.as_dict() == expected