def test_macOS_custom_notificator():
    custom_notificator_path = str(
        pathlib.Path(__file__).resolve().parent / "Notificator.app")
    n = notifypy.Notify(custom_mac_notificator=custom_notificator_path)
    assert (n._notifier._notificator_binary == custom_notificator_path +
            "/Contents/Resources/Scripts/notificator")
    assert n.send() == True
Exemple #2
0
def test_custom_notification():
    class CustomNotificator(BaseNotifier):
        def __init__(self, **kwargs):
            pass

    n = notifypy.Notify(use_custom_notifier=CustomNotificator)
    assert n._notifier_detect == CustomNotificator
def test_invalid_custom_notification():
    class CustomNotificator:
        pass

    with pytest.raises(ValueError):
        notifypy.Notify(
            override_detected_notification_system=CustomNotificator)
def test_custom_notification():
    class CustomNotificator(BaseNotifier):
        def __init__(self, **kwargs):
            pass

    n = notifypy.Notify(
        override_detected_notification_system=CustomNotificator)
    assert n._notifier_detect == CustomNotificator
Exemple #5
0
def test_multiline_notification():
    n = notifypy.Notify()
    n.message = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit, 
sed do eiusmod tempor incididunt ut labore et dolore magna 
aliqua. Ut enim ad minim veniam, quis nostrud exercitation 
ullamco laboris nisi ut aliquip ex ea commodo consequat. 
Duis aute irure dolor in reprehenderit in voluptate velit 
esse cillum dolore eu fugiat nulla pariatur. 
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
"""
    assert n.send() == True
Exemple #6
0
async def friends_update(connection, event):
    friends = await connection.request("get", "/lol-chat/v1/friends")
    friends_json = await friends.json()

    global last_friends
    if len(friends_json) != len(last_friends):
        # Do nothing if there is a change in the length of the friends list.
        # This will miss some information if a friend changes state in this
        # exact hook timing but that's too unlikely to worry about.
        # Note: This will not miss anything if the client limits to a maximum
        # of one change per each "UPDATE" event, but that is unclear.
        return [last_friends := friends_json]

    for i, f in enumerate(friends_json):
        # Availability values represent the following.
        # - away: User is in the `Away` state.
        # - chat: User is in the `Online` state.
        # - dnd: User is in one of `In Queue`, `Champ Select`, or `In Game`.
        # - mobile: User is in the `League+` state.
        # - offline: User is in the `Offline` state.

        if searched_groups and f.get("groupName") not in searched_groups:
            continue
        if time.monotonic() < game_lockout_end and f.get(
                "summonerId") in last_game_participants:
            continue

        last_availability = last_friends[i].get("availability")
        if f.get("availability") == "chat" and last_availability != "chat":
            notification = notifypy.Notify()
            notification.title = "LoLNotifier"
            notification.message = status_message[last_availability].format(
                name=f.get("name"))
            if os.path.isfile(icon_path):
                notification.icon = icon_path
            notification.send(block=False)

            print(notification.message)

    last_friends = friends_json
Exemple #7
0
def test_custom_audio():
    n = notifypy.Notify()
    n.audio = "notifypy/example_notification_sound.wav"
    assert n.send() == True
Exemple #8
0
def test_blocking_notification():
    n = notifypy.Notify()
    assert n.send(block=True) == True
Exemple #9
0
def test_non_blocking_notification():
    n = notifypy.Notify()
    thread_notify = n.send(block=False)
    assert thread_notify.wait()
Exemple #10
0
def test_blank_title_notification():
    n = notifypy.Notify()
    n.title = ""
    assert n.send() == True
Exemple #11
0
def test_rtl_language_notification():
    n = notifypy.Notify()
    n.title = "مرحبا كيف الحال؟"
    assert n.send() == True
Exemple #12
0
def test_custom_audio_no_file():
    n = notifypy.Notify()
    with pytest.raises(notifypy.exceptions.InvalidAudioFormat):
        n.audio = "not a file!"
Exemple #13
0
def test_blank_message_notification():
    n = notifypy.Notify()
    n.message = ""
    assert n.send() == True
Exemple #14
0
def test_notification_with_double_quotes():
    n = notifypy.Notify()
    n.title = '" Yes "Yes"'
    assert n.send() == True
Exemple #15
0
def test_notification_with_special_chars():
    n = notifypy.Notify()
    n.message = '"""""; """ ;;# ##>>> <<>>< </>'
    assert n.send() == True
Exemple #16
0
import time as tm
import notifypy as ntp
import playsound as ps

ntimes = ['8:30', '9:25', '10:20', '11:25', '12:30', '13:25', '14:20', '15:15']

img = 'img/video-call.png'
startSfx = 'sfx/ntfsound.wav'

ntfStart = ntp.Notify()
ntfStart.application_name = 'Time Manager'
ntfStart.title = 'Enabled'
ntfStart.message = 'Notifier is now enabled'
ntfStart.audio = startSfx
ntfStart.icon = img
ntfStart.send(block=True)

path = 'sfx/asound.wav'
ntf = ntp.Notify()
ntf.icon = img
ntf.audio = path
ntf.application_name = 'Time Manager'

while True:
    timeNow = tm.localtime()
    hour = str(timeNow[3])
    minute = str(timeNow[4])
    sec = str(timeNow[5])
    """months = {1: 'Jan', 2: ' Feb', 3: 'Mar', 4: 'Apr', 5: 'May', 6: 'Jun',
            7: 'Jul', 8: 'Aug', 9: 'Sep', 10: 'Oct', 11: 'Nov', 12: 'Dec'}
    days = {0: 'Mon', 1: 'Tue', 2: 'Wed', 3: 'Thu', 4: 'Fri', 5: 'Sat', 6: 'Sun'}"""
Exemple #17
0
def test_invalid_audio_format_default():
    with pytest.raises(notifypy.exceptions.InvalidAudioFormat):
        n = notifypy.Notify(default_notification_audio="asdfiojasdfioj")
Exemple #18
0
def test_invalid_audio_default():
    with pytest.raises(notifypy.exceptions.InvalidAudioPath):
        n = notifypy.Notify(default_notification_audio="dsaiofj/sadf/vv.wav")
Exemple #19
0
def test_invalid_icon_default():
    with pytest.raises(notifypy.exceptions.InvalidIconPath):
        n = notifypy.Notify(default_notification_icon="sadfiasjdfisaodfj")
Exemple #20
0
def test_non_existant_icon():
    n = notifypy.Notify()
    with pytest.raises(notifypy.exceptions.InvalidIconPath):
        n.icon = "ttt"
Exemple #21
0
def test_custom_audio_no_file():
    n = notifypy.Notify()
    with pytest.raises(ValueError):
        n.audio = "not a file!"
Exemple #22
0
def test_normal_notification():
    n = notifypy.Notify()
    assert n.send() == True
Exemple #23
0
def test_notification_with_emoji():
    n = notifypy.Notify()
    n.title = "🐐"
    n.message = "also known as Kanye West"
Exemple #24
0
def test_invalid_custom_notification():
    class CustomNotificator:
        pass

    with pytest.raises(ValueError):
        notifypy.Notify(use_custom_notifier=CustomNotificator)