Changeset 9125 for main/waeup.kofa/trunk


Ignore:
Timestamp:
30 Aug 2012, 07:26:27 (12 years ago)
Author:
Henrik Bettermann
Message:

Add removeMessage to ObjectHistory? class which removes a single history message.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/objecthistory.py

    r9013 r9125  
    9292        self._annotations[self.history_key] = new_msgs
    9393        return
     94
     95    def removeMessage(self, number):
     96        """Removes a single history message.
     97
     98        """
     99        msgs = self._getMessages()
     100        msgs.pop(number)
     101        self._annotations[self.history_key] = msgs
     102        return
  • main/waeup.kofa/trunk/src/waeup/kofa/tests/test_objecthistory.py

    r9012 r9125  
    101101        self.assertMatches('<YYYY-MM-DD hh:mm:ss> UTC - blow by Bob', result)
    102102
     103    def test_remove_message(self):
     104        principal = Principal('bob')
     105        principal.title = 'Bob'
     106        newInteraction(Participation(principal)) # set current user
     107        hist = IObjectHistory(self.obj)
     108        hist.addMessage('blah')
     109        hist.addMessage('blow')
     110        self.assertEqual(len(hist._getMessages()),2)
     111        result = ' '.join(hist.messages)
     112        self.assertTrue('blah by Bob' in result)
     113        self.assertTrue('blow by Bob' in result)
     114        hist.removeMessage(1)
     115        self.assertEqual(len(hist._getMessages()),1)
     116        result = ' '.join(hist.messages)
     117        self.assertFalse('blow by Bob' in result)
     118
    103119    def test_messages(self):
    104120        # we get messages as a persistent list of strings
Note: See TracChangeset for help on using the changeset viewer.