Commits

Olemis Lang  committed 3c3d2fb

Trac #11148 : 'IMilestoneChangeListener' notifications powered by 'ListenerNotifier.notify' [ok]

  • Participants
  • Parent commits 817030f
  • Branches trac_t11148

Comments (0)

Files changed (3)

 t11148/t11148_r11782_IEntityChangeListener_v2.diff
 t11148/t11148_r11784_IEntityListener_compat_attachment.diff
+t11148/t11148_r11784_IEntityListener_compat_ticket.diff
 #t11148/t11148_r11767_IResourceChangeListener.diff

File t11148/t11148_r11784_IEntityListener_compat_attachment.diff

 # HG changeset patch
-# Parent e01d7454b5fe56724d7abd0c80143e78aa8deb77
-Trac #11148 : 'IAttachmentListener' notifications powered by 'ListenerNotifier.notify'
+# Parent 2d08b51bc080f4fe2248580a60027fa76f138697
+Trac #11148 : 'IAttachmentChangeListener' notifications powered by 'ListenerNotifier.notify'
 
-diff -r e01d7454b5fe trac/attachment.py
---- a/trac/attachment.py	Fri Apr 26 00:27:27 2013 -0500
-+++ b/trac/attachment.py	Fri Apr 26 00:59:58 2013 -0500
+diff -r 2d08b51bc080 trac/attachment.py
+--- a/trac/attachment.py	Sat Apr 27 16:41:50 2013 -0500
++++ b/trac/attachment.py	Sat Apr 27 16:50:19 2013 -0500
 @@ -34,6 +34,7 @@
                         console_datetime_format, get_dir_list
  from trac.config import BoolOption, IntOption
  
  
      @classmethod
-diff -r e01d7454b5fe trac/tests/attachment.py
---- a/trac/tests/attachment.py	Fri Apr 26 00:27:27 2013 -0500
-+++ b/trac/tests/attachment.py	Fri Apr 26 00:59:58 2013 -0500
+diff -r 2d08b51bc080 trac/tests/attachment.py
+--- a/trac/tests/attachment.py	Sat Apr 27 16:41:50 2013 -0500
++++ b/trac/tests/attachment.py	Sat Apr 27 16:50:19 2013 -0500
 @@ -6,11 +6,13 @@
  import tempfile
  import unittest

File t11148/t11148_r11784_IEntityListener_compat_ticket.diff

+# HG changeset patch
+# Parent 2c0e5eb15b91dc6952dcb8c0866631ff7cb9fcab
+Trac #11148 : 'ITicketChangeListener' , 'IMilestoneChangeListener' notifications powered by 'ListenerNotifier.notify'
+
+diff -r 2c0e5eb15b91 trac/ticket/model.py
+--- a/trac/ticket/model.py	Sat Apr 27 16:50:19 2013 -0500
++++ b/trac/ticket/model.py	Sat Apr 27 17:39:07 2013 -0500
+@@ -1116,8 +1116,8 @@
+             del self.cache.milestones
+             TicketSystem(self.env).reset_ticket_fields()
+ 
+-        for listener in TicketSystem(self.env).milestone_change_listeners:
+-            listener.milestone_deleted(self)
++        ListenerNotifier(self.env).notify(
++                IMilestoneChangeListener.milestone_deleted, entity=self)
+ 
+     def insert(self, db=None):
+         """Insert a new milestone.
+@@ -1138,8 +1138,8 @@
+             self.checkin()
+             TicketSystem(self.env).reset_ticket_fields()
+ 
+-        for listener in TicketSystem(self.env).milestone_change_listeners:
+-            listener.milestone_created(self)
++        ListenerNotifier(self.env).notify(
++                IMilestoneChangeListener.milestone_created, entity=self)
+ 
+     def update(self, db=None):
+         """Update the milestone.
+@@ -1177,8 +1177,9 @@
+ 
+         old_values = dict((k, v) for k, v in old.iteritems()
+                           if getattr(self, k) != v)
+-        for listener in TicketSystem(self.env).milestone_change_listeners:
+-            listener.milestone_changed(self, old_values)
++        ListenerNotifier(self.env).notify(
++                IMilestoneChangeListener.milestone_changed,
++                entity=self, old_values=old_values)
+ 
+     @classmethod
+     def select(cls, env, include_completed=True, db=None):
+diff -r 2c0e5eb15b91 trac/ticket/tests/model.py
+--- a/trac/ticket/tests/model.py	Sat Apr 27 16:50:19 2013 -0500
++++ b/trac/ticket/tests/model.py	Sat Apr 27 17:39:07 2013 -0500
+@@ -993,13 +993,20 @@
+ 
+     def test_change_listener_created(self):
+         listener = TestMilestoneChangeListener(self.env)
++        generic_listener = GenericEntitiesChangeListenerMock(self.env)
++
+         milestone = self._create_milestone(name='Milestone 1')
+         milestone.insert()
+         self.assertEqual('created', listener.action)
+         self.assertEqual(milestone, listener.milestone)
+ 
++        self.assertEqual([{'action' : 'created', 'entity' : milestone}], 
++                         generic_listener.details)
++
+     def test_change_listener_changed(self):
+         listener = TestMilestoneChangeListener(self.env)
++        generic_listener = GenericEntitiesChangeListenerMock(self.env)
++
+         milestone = self._create_milestone(
+             name='Milestone 1',
+             due=datetime(2001, 01, 01, tzinfo=utc),
+@@ -1017,8 +1024,18 @@
+                           'description': 'The milestone description'},
+                          listener.old_values)
+ 
++        self.assertEqual([{'action' : 'created', 'entity' : milestone},
++                          {'action' : 'changed', 'entity' : milestone,
++                           'old_values' : {'name': 'Milestone 1', 
++                                           'completed': None,
++                                           'description': 'The milestone '
++                                                          'description'}}], 
++                         generic_listener.details)
++
+     def test_change_listener_deleted(self):
+         listener = TestMilestoneChangeListener(self.env)
++        generic_listener = GenericEntitiesChangeListenerMock(self.env)
++
+         milestone = self._create_milestone(name='Milestone 1')
+         milestone.insert()
+         self.assertEqual(True, milestone.exists)
+@@ -1028,6 +1045,10 @@
+         self.assertEqual('deleted', listener.action)
+         self.assertEqual(milestone, listener.milestone)
+ 
++        self.assertEqual([{'action' : 'created', 'entity' : milestone},
++                          {'action' : 'deleted', 'entity' : milestone}], 
++                         generic_listener.details)
++
+ 
+ class ComponentTestCase(unittest.TestCase):
+