Exemple #1
0
 def test_conversation_add_message(self):
     from plonesocial.messaging.messaging import Message
     conversation = self._create_conversation('inbox_user', 'other_user')
     message = Message('inbox_user', 'other_user', 'test', now())
     conversation.add_message(message)
     messages = conversation.get_messages()
     self.assertEqual(list(messages), [message])
Exemple #2
0
 def test_message_attributes(self):
     from plonesocial.messaging.messaging import Message
     _now = now()
     message = Message('sender', 'recipient', 'text', _now)
     self.assertEqual(message.sender, 'sender')
     self.assertEqual(message.recipient, 'recipient')
     self.assertEqual(message.text, 'text')
     self.assertEqual(message.created, _now)
Exemple #3
0
    def test_conversation_add_message_increases_inbox_unread_count(self):
        from plonesocial.messaging.messaging import Message
        conversation = self._create_conversation('inbox_user', 'other_user')
        inbox = conversation.__parent__
        self.assertEqual(inbox.new_messages_count, 0)

        message = Message('inbox_user', 'other_user', 'test', now())
        conversation.add_message(message)
        self.assertEqual(inbox.new_messages_count, 1)
Exemple #4
0
    def test_conversation_delete_message_decreases_unread_count(self):
        from plonesocial.messaging.messaging import Message
        conversation = self._create_conversation('inbox_user', 'other_user')
        message = Message('inbox_user', 'other_user', 'test', now())
        uid = conversation.add_message(message)
        self.assertEqual(conversation.new_messages_count, 1)

        del conversation[uid]
        self.assertEqual(conversation.new_messages_count, 0)
Exemple #5
0
    def test_conversation_add_message_increases_unread_count(self):
        from plonesocial.messaging.messaging import Message
        conversation = self._create_conversation('inbox_user', 'other_user')
        self.assertEqual(conversation.new_messages_count, 0)

        message = Message('inbox_user', 'other_user', 'test', now())
        conversation.add_message(message)
        self.assertEqual(list(conversation.get_messages())[0].new, True)
        self.assertEqual(conversation.new_messages_count, 1)
Exemple #6
0
    def test_conversation_mark_read(self):
        from plonesocial.messaging.messaging import Message
        conversation = self._create_conversation('inbox_user', 'other_user')
        message = Message('inbox_user', 'other_user', 'test', now())
        conversation.add_message(message)
        self.assertEqual(message.new, True)

        conversation.mark_read()
        self.assertEqual(conversation.new_messages_count, 0)
        self.assertEqual(message.new, False)
Exemple #7
0
    def test_conversation_dictapi_delete_message(self):
        from plonesocial.messaging.messaging import Message
        conversation = self._create_conversation('inbox_user', 'other_user')

        message = Message('inbox_user', 'other_user', 'test', now())
        uid = conversation.add_message(message)
        self.assertEqual(list(conversation.get_messages()), [message])

        del conversation[uid]
        self.assertEqual(list(conversation.get_messages()), [])