Example #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
Example #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')
Example #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')
Example #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')
Example #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')
Example #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)
Example #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)
Example #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')
Example #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')
Example #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)
Example #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)
Example #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)
Example #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')
Example #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)
Example #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')
Example #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')
Example #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)
Example #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')
Example #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')
Example #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')
Example #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)
Example #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')
Example #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')
Example #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)
Example #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)
Example #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
Example #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
Example #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
Example #29
0
def test_Cause():
    expected = {'type': 'PHYSICAL_INTERACTION'}
    a = ASHO.Cause(type='PHYSICAL_INTERACTION')
    a.validate()
    assert a.as_dict() == expected
Example #30
0
def test_CallSign():
    expected = 'NBC4'
    a = ASHO.CallSign('NBC4')
    a.validate()
    assert a.as_dict() == expected