# 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
from pyecore.ecore import *
from pyecore.notification import EObserver, Kind
    root.namedElements.append(a1)


def test_notification_print(lib):
    root = lib.Root()
    a1 = lib.A()
    observer = EObserver()
    observer.observe(root)
    observer.notify = lambda x: print(x)
    root.namedElements.append(a1)


def test_notification_add(lib):
    root = lib.Root()
    a1 = lib.A()
    notifyChanged = lambda x: assert_wrap(x.kind is Kind.ADD
                                          and x.new is a1
                                          and x.feature.name == 'namedElements'
                                          and x.notifier is root)
    observer = EObserver(root, notifyChanged=notifyChanged)
    root.namedElements.append(a1)


def test_notification_eopposite(lib):
    a1 = lib.A()
    b1 = lib.B()
    notify = lambda x: assert_wrap(x.kind is Kind.ADD
                                   and x.new is a1
                                   and x.feature.name == 'inner'
                                   and x.notifier is b1)

# 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/test_dynamic_notifications.py
import pytest
from pyecore.ecore import *
from pyecore.notification import EObserver, Kind

    root.namedElements.append(a1)


def test_notification_print(lib):
    root = lib.Root()
    a1 = lib.A()
    observer = EObserver()
    observer.observe(root)
    observer.notify = lambda x: print(x)
    root.namedElements.append(a1)


def test_notification_add(lib):
    root = lib.Root()
    a1 = lib.A()
    notifyChanged = lambda x: assert_wrap(x.kind is Kind.ADD
                                          and x.new is a1
                                          and x.feature.name == 'namedElements'
                                          and x.notifier is root)
    observer = EObserver(root, notifyChanged=notifyChanged)
    root.namedElements.append(a1)


def test_notification_eopposite(lib):
    a1 = lib.A()
    b1 = lib.B()
    notify = lambda x: assert_wrap(x.kind is Kind.ADD
                                   and x.new is a1
                                   and x.feature.name == 'inner'
                                   and x.notifier is b1)

    o1 = EObserver(b1, notifyChanged=notify)