Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 3
0
    def coro():
        h = SNPHandler(loop=loop)

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

        response = yield from h.register(notifier, t)
        assert response['status'] == 'OK'
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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'
Ejemplo n.º 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'
Ejemplo n.º 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'
Ejemplo n.º 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'
Ejemplo n.º 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'
Ejemplo n.º 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'
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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'
Ejemplo n.º 15
0
    def coro():
        h = SNPHandler(loop=loop)
        t = Target('snp://%s' % INVALID_HOST)

        with pytest.raises(ConnectionError):
            _protocol = yield from h.connect(t)
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 19
0
def test_Target_String_UsernamePasswordIsRemoved():
    t = Target('snp://*****:*****@192.168.1.1:9000')
    assert str(t) == 'snp://192.168.1.1:9000'
Ejemplo n.º 20
0
def test_Target_IsRemote():
    t = Target('snp://[email protected]:9000')
    assert t.is_remote
Ejemplo n.º 21
0
def testTargetList_Append():
    t = TargetList()
    t.append(Target('kodi://192.168.1.1'))
    assert len(t.targets) == 1
Ejemplo n.º 22
0
def remote_target():
    return Target('gntp://%s:%d' % (REMOTE_HOST, GNTP_DEFAULT_PORT))
Ejemplo n.º 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)
Ejemplo n.º 24
0
def test_SNPTarget_Init_Empty():
    t = Target('snp')
    assert t.scheme == 'snp'
    assert t.host == '127.0.0.1'
Ejemplo n.º 25
0
 def coro():
     h = SNPHandler(loop=loop)
     t = Target('snp://%s' % HOST)
     _protocol = yield from h.connect(t)
     assert t.handler == h
Ejemplo n.º 26
0
def test_BadProtocol():
    with pytest.raises(TargetError):
        t = Target('wally')
Ejemplo n.º 27
0
def test_PushoverTarget_Init():
    t = Target('po://adkhkahs')
    assert t.scheme == 'po'
    assert t.host == 'adkhkahs'
Ejemplo n.º 28
0
def test_ProwlTarget_Init():
    t = Target('prowl://adkhkahs')
    assert t.scheme == 'prowl'
    assert t.host == 'adkhkahs'
Ejemplo n.º 29
0
def local_target():
    return Target('gntp://%s:%d' % (HOST, GNTP_DEFAULT_PORT))
Ejemplo n.º 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'