# Path: pyecore/notification.py
# class EObserver(object):
#     def __init__(self, notifier=None, notifyChanged=None):
#         if notifier:
#             notifier.listeners.append(self)
#         if notifyChanged:
#             self.notifyChanged = notifyChanged
# 
#     def observe(self, notifier):
#         notifier.listeners.append(self)
# 
#     def notifyChanged(self, notification):
#         pass
# 
# class Kind(Enum):
#     ADD = 0
#     ADD_MANY = 1
#     MOVE = 2
#     REMOVE = 3
#     REMOVE_MANY = 4
#     SET = 5
#     UNSET = 6


import pytest
import library as lib
from pyecore.notification import EObserver, Kind


class LastNotification(EObserver):
    def __init__(self, notifier=None):
        super().__init__(notifier=notifier)
        self.notification = None

    def notifyChanged(self, notification):
        self.notification = notification


def test_notification_static_set():
    library = lib.Library()
    o = LastNotification(library)
    library.name = 'SuperLib'
    notif = o.notification
    assert notif.kind is Kind.SET
    assert notif.new == 'SuperLib'
    assert notif.old is None
    assert notif.feature is lib.Library.name


def test_notification_static_unset():
    library = lib.Library()
    o = LastNotification(library)
    library.name = 'SuperLib'
    library.name = None
    notif = o.notification

# Path: pyecore/notification.py
# class EObserver(object):
#     def __init__(self, notifier=None, notifyChanged=None):
#         if notifier:
#             notifier.listeners.append(self)
#         if notifyChanged:
#             self.notifyChanged = notifyChanged
# 
#     def observe(self, notifier):
#         notifier.listeners.append(self)
# 
#     def notifyChanged(self, notification):
#         pass
# 
# class Kind(Enum):
#     ADD = 0
#     ADD_MANY = 1
#     MOVE = 2
#     REMOVE = 3
#     REMOVE_MANY = 4
#     SET = 5
#     UNSET = 6


# Path: tests/wikilibrary/test_static_notifications.py
import pytest
import library as lib
from pyecore.notification import EObserver, Kind



class LastNotification(EObserver):
    def __init__(self, notifier=None):
        super().__init__(notifier=notifier)
        self.notification = None

    def notifyChanged(self, notification):
        self.notification = notification


def test_notification_static_set():
    library = lib.Library()
    o = LastNotification(library)
    library.name = 'SuperLib'
    notif = o.notification
    assert notif.kind is Kind.SET
    assert notif.new == 'SuperLib'
    assert notif.old is None
    assert notif.feature is lib.Library.name


def test_notification_static_unset():
    library = lib.Library()
    o = LastNotification(library)
    library.name = 'SuperLib'
    library.name = None
    notif = o.notification

    assert notif.kind is Kind.UNSET