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