示例#1
0
    def coro():
        #target = Target('snp://%s' % HOST)
        t1 = Target('gntp://%s' % HOST)
        t2 = Target('xbmc://%s' % HOST)

        notification = async_notifier.create_notification(
            name='New',
            title='One notification',
            text='Sent to multiple targets')

        _response = yield from async_notifier.add_target([t1, t2])
        _response = yield from async_notifier.notify(notification)
        pass
示例#2
0
def test_Target_Init_EmptyTarget():
    t = Target()
    assert t.scheme == 'snp'
    assert t.host == '127.0.0.1'
    assert t.port == -1
    assert t.username is None
    assert t.password is None
示例#3
0
    def coro():
        h = SNPHandler(loop=loop)

        t = Target('snp://%s' % HOST)

        response = yield from h.register(notifier, t)
        assert response['status'] == 'OK'
示例#4
0
    def coro():
        #target = Target('snp://%s' % HOST)
        target = Target('gntp://%s' % HOST)

        _response = yield from async_notifier.add_target(target)
        _response = yield from async_notifier.register(target)
        pass
示例#5
0
def test_Target_Init_WithUsernamePasswordAndPort():
    t = Target('snp://*****:*****@192.168.1.1:9000')
    assert t.scheme == 'snp'
    assert t.host == '192.168.1.1'
    assert t.username == 'user'
    assert t.password == 'wally'
    assert t.port == 9000
示例#6
0
    def coro():
        h = SNPHandler(loop=loop)

        t = Target('snp://%s' % HOST)

        yield from notifier.add_target(t)
        response = yield from h.subscribe(notifier, [], t)
        assert response['status'] == 'OK'
示例#7
0
    def coro():
        h = SNPHandler(loop=loop)

        t = Target('snp://%s' % HOST)

        notification = notifier.create_notification(name='New',
                                                    title="A brave new world",
                                                    text="Say hello to Prism")
        response = yield from h.notify(notification, t)
        assert response['status'] == 'OK'
示例#8
0
    def coro():
        h = PushoverHandler(apptoken='a23MprXQ5P4weDkKWLXR3swDjGa68q', loop=loop)

        t = Target('po://uDyCFupvhfxXcC5GSCvYw7ZUwzeoYa')

        notification = notifier.create_notification(name='New',
                                             title="A brave new world",
                                             text="Say hello to Prism")
        logging.debug('Pushover: notify bad app token')
        response = yield from h.notify(notification, t)
        assert response['status'] == 'ERROR'
示例#9
0
    def coro():
        h = SNPHandler(loop=loop)

        t = Target('snp://%s' % HOST)

        notification = notifier.create_notification(name='New',
                                                    title="With URL call back",
                                                    text="Press me")
        notification.add_callback('http://news.bbc.co.uk/sport')
        response = yield from h.notify(notification, t)
        assert response['status'] == 'OK'
示例#10
0
    def coro():
        h = PushbulletHandler(loop=loop)

        t = Target('pb://gBfoLoTocaLSQJtM7rWEJaEAPf5Pf')

        notification = notifier.create_notification(name='New',
                                             title="A brave new world",
                                             text="Say hello to Prism")
        logging.debug('Pushbullet: notify bad app token')
        response = yield from h.notify(notification, t)
        assert response['status'] == 'ERROR'
示例#11
0
    def coro():
        h = SNPHandler(loop=loop)

        t = Target('snp://%s' % REMOTE_HOST)

        notification = notifier.create_notification(
            name='New',
            title="A brave new world",
            text="This notification should have an icon",
            icon=icon_inverted)
        response = yield from h.notify(notification, t)
        assert response['status'] == 'OK'
示例#12
0
    def coro():
        #target = Target('snp://%s' % HOST)
        target = Target('gntp://%s' % HOST)

        notification = async_notifier.create_notification(
            name='Old',
            title='A notification',
            text='This is a wonderful notification')

        _response = yield from async_notifier.add_target(target)
        _response = yield from async_notifier.notify(notification, target)
        pass
示例#13
0
    def coro():
        h = XBMCHandler(loop=loop)

        t = Target('xbmc://%s' % HOST)

        notification = notifier.create_notification(name='New',
                                                    title="A brave new world",
                                                    text="Say hello to Prism",
                                                    icon='info')
        response = yield from h.notify(notification, t)
        if response['status'] == 'ERROR':
            assert response['reason'] == 'All hosts are unreachable.'
        else:
            assert response['status_code'] == 0
示例#14
0
def test_SNPTarget_Init_HostOnly():
    t = Target('snp://192.168.1.1')
    assert t.scheme == 'snp'
    assert t.host == '192.168.1.1'
示例#15
0
    def coro():
        h = SNPHandler(loop=loop)
        t = Target('snp://%s' % INVALID_HOST)

        with pytest.raises(ConnectionError):
            _protocol = yield from h.connect(t)
示例#16
0
def test_Target_Init_WithPassword():
    t = Target('snp://:[email protected]')
    assert t.scheme == 'snp'
    assert t.host == '192.168.1.1'
    assert t.password == 'wally'
    assert t.port == -1
示例#17
0
def test_Target_Init_WithUsernameAndPort():
    t = Target('snp://[email protected]:8080')
    assert t.scheme == 'snp'
    assert t.host == '192.168.1.1'
    assert t.username == 'wally'
    assert t.port == 8080
示例#18
0
def testTargetList_Append():
    t = TargetList()
    kt = Target('kodi://192.168.1.1')
    t.targets.append(kt)
    t.remove(kt)
    assert len(t.targets) == 0
示例#19
0
def test_Target_String_UsernamePasswordIsRemoved():
    t = Target('snp://*****:*****@192.168.1.1:9000')
    assert str(t) == 'snp://192.168.1.1:9000'
示例#20
0
def test_Target_IsRemote():
    t = Target('snp://[email protected]:9000')
    assert t.is_remote
示例#21
0
def testTargetList_Append():
    t = TargetList()
    t.append(Target('kodi://192.168.1.1'))
    assert len(t.targets) == 1
示例#22
0
def remote_target():
    return Target('gntp://%s:%d' % (REMOTE_HOST, GNTP_DEFAULT_PORT))
示例#23
0
    def coro():
        h = GNTPHandler(loop=loop)
        t = Target('gntp://%s' % INVALID_HOST)

        with pytest.raises((ConnectionError, TimeoutError)):
            _protocol = yield from h.connect(t)
示例#24
0
def test_SNPTarget_Init_Empty():
    t = Target('snp')
    assert t.scheme == 'snp'
    assert t.host == '127.0.0.1'
示例#25
0
 def coro():
     h = SNPHandler(loop=loop)
     t = Target('snp://%s' % HOST)
     _protocol = yield from h.connect(t)
     assert t.handler == h
示例#26
0
def test_BadProtocol():
    with pytest.raises(TargetError):
        t = Target('wally')
示例#27
0
def test_PushoverTarget_Init():
    t = Target('po://adkhkahs')
    assert t.scheme == 'po'
    assert t.host == 'adkhkahs'
示例#28
0
def test_ProwlTarget_Init():
    t = Target('prowl://adkhkahs')
    assert t.scheme == 'prowl'
    assert t.host == 'adkhkahs'
示例#29
0
def local_target():
    return Target('gntp://%s:%d' % (HOST, GNTP_DEFAULT_PORT))
示例#30
0
def test_GNTPTarget_Init_Host():
    t = Target('gntp://192.168.1.1')
    assert t.scheme == 'gntp'
    assert t.host == '192.168.1.1'