# 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
    from pyecore.resources import Resource
        self.feature = notification.feature


def test_notification_add_onecall():
    root = EPackage(name='test')
    A = EClass('A')
    o1 = ObserverCounter(root)
    o2 = ObserverCounter(A)
    root.eClassifiers.append(A)
    assert o1.calls == 1
    assert o1.kind == Kind.ADD
    assert o1.feature is EPackage.eClassifiers
    assert o2.calls == 1
    assert o2.kind == Kind.SET
    assert o2.feature is EClassifier.ePackage


def test_notification_remove_onecall():
    root = EPackage(name='test')
    A = EClass('A')
    root.eClassifiers.append(A)

    o1 = ObserverCounter(root)
    o2 = ObserverCounter(A)
    root.eClassifiers.remove(A)
    assert o1.calls == 1
    assert o1.kind == Kind.REMOVE
    assert o1.feature is EPackage.eClassifiers
    assert o2.calls == 1
    assert o2.kind == Kind.UNSET

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

        self.feature = notification.feature


def test_notification_add_onecall():
    root = EPackage(name='test')
    A = EClass('A')
    o1 = ObserverCounter(root)
    o2 = ObserverCounter(A)
    root.eClassifiers.append(A)
    assert o1.calls == 1
    assert o1.kind == Kind.ADD
    assert o1.feature is EPackage.eClassifiers
    assert o2.calls == 1
    assert o2.kind == Kind.SET
    assert o2.feature is EClassifier.ePackage


def test_notification_remove_onecall():
    root = EPackage(name='test')
    A = EClass('A')
    root.eClassifiers.append(A)

    o1 = ObserverCounter(root)
    o2 = ObserverCounter(A)
    root.eClassifiers.remove(A)
    assert o1.calls == 1
    assert o1.kind == Kind.REMOVE
    assert o1.feature is EPackage.eClassifiers
    assert o2.calls == 1
    assert o2.kind == Kind.UNSET

    assert o2.feature is EClassifier.ePackage