示例#1
0
 def test_inbox_get_conversations(self):
     from plonesocial.messaging.messaging import Conversation
     inbox = self._create_inbox()
     inbox.add_conversation(Conversation('otheruser', now()))
     inbox.add_conversation(Conversation('thirduser', now()))
     conversations = inbox.get_conversations()
     self.assertEqual(len(conversations), 2)
     self.assertEqual(type(conversations[0]), Conversation)
     self.assertEqual(type(conversations[1]), Conversation)
     self.assertTrue(conversations[0] != conversations[1])
示例#2
0
    def test_inbox_dictapi_add_conversation_checks_users(self):
        from plonesocial.messaging.messaging import Conversation
        inbox = self._create_inbox('testuser')
        conversation = Conversation('testuser', now())
        with self.assertRaises(ValueError) as cm:
            inbox['testuser'] = conversation

        self.assertEqual(cm.exception.message, "You can't speak to yourself")
示例#3
0
 def _create_conversation(self, inbox_user='******',
                          other_user='******',
                          created=None):
     from plonesocial.messaging.messaging import Conversation
     if created is None:
         created = now()
     inbox = self._create_inbox(username=inbox_user)
     return inbox.add_conversation(Conversation(other_user, created))
示例#4
0
    def test_inbox_delete_conversation(self):
        from plonesocial.messaging.messaging import Conversation
        inbox = self._create_inbox()
        inbox.add_conversation(Conversation('otheruser', now()))
        conversations = inbox.get_conversations()
        self.assertEqual(len(conversations), 1)

        del inbox['otheruser']
        conversations = inbox.get_conversations()
        self.assertEqual(len(conversations), 0)
示例#5
0
 def test_inbox_dictapi_add_conversation_checks_key(self):
     from plonesocial.messaging.messaging import Conversation
     inbox = self._create_inbox()
     conversation = Conversation('otheruser', now())
     with self.assertRaises(KeyError):
         inbox['brokenkey'] = conversation
示例#6
0
 def test_inbox_dictapi_add_conversation_adds_parent(self):
     from plonesocial.messaging.messaging import Conversation
     inbox = self._create_inbox()
     conversation = Conversation('otheruser', now())
     inbox[conversation.username] = conversation
     self.assertTrue(conversation.__parent__ is inbox)
示例#7
0
 def test_inbox_add_conversation(self):
     from plonesocial.messaging.messaging import Conversation
     inbox = self._create_inbox()
     conversation = Conversation('otheruser', now())
     inbox.add_conversation(conversation)
     self.assertTrue(conversation is inbox[conversation.username])
示例#8
0
 def test_inbox_dictapi_add_conversation(self):
     from plonesocial.messaging.messaging import Conversation
     inbox = self._create_inbox()
     conversation = Conversation('otheruser', now())
     inbox[conversation.username] = conversation
     self.assertIs(conversation, inbox[conversation.username])
示例#9
0
 def test_inbox_add_conversation_adds_parent(self):
     from plonesocial.messaging.messaging import Conversation
     inbox = self._create_inbox()
     conversation = Conversation('otheruser', now())
     inbox.add_conversation(conversation)
     self.assertIs(conversation.__parent__, inbox)