Beispiel #1
0
    def test_leave(self):
        user = UserFactory()
        conversation = ConversationFactory(participants=[user])
        self.assertIn(user, conversation.participants.all())

        conversation.leave(user)
        self.assertNotIn(user, conversation.participants.all())
Beispiel #2
0
    def tests_receive_message_on_leave(self):
        user = UserFactory()
        author = UserFactory()
        # join a conversation
        conversation = ConversationFactory(participants=[user, author])
        # write a message
        ConversationMessage.objects.create(conversation=conversation,
                                           content='yay',
                                           author=author)

        # login and connect
        client = self.connect_as(user)

        conversation.leave(user)
        messages = client.messages_by_topic
        self.assertEqual(len(messages['conversations:leave']), 1,
                         messages['conversations:leave'])
        self.assertEqual(messages['conversations:leave'][0]['payload'],
                         {'id': conversation.id})

        self.assertEqual(len(messages['status']), 1, messages['status'])
        self.assertEqual(
            messages['status'][0]['payload'], {
                'unseen_thread_count': 0,
                'unseen_conversation_count': 0,
                'has_unread_conversations_or_threads': False,
                'groups': {},
                'places': {},
            })
Beispiel #3
0
    def test_other_participants_receive_update_on_leave(self):
        user = UserFactory()
        leaving_user = UserFactory()

        # join a conversation
        conversation = ConversationFactory(participants=[user, leaving_user])

        # login and connect
        client = self.connect_as(user)

        conversation.leave(leaving_user)

        response = client.messages_by_topic['conversations:conversation'][0]
        self.assertEqual(response['payload']['participants'], [user.id])
    def tests_receive_message_on_leave(self):
        user = UserFactory()

        # join a conversation
        conversation = ConversationFactory(participants=[
            user,
        ])

        # login and connect
        client = self.connect_as(user)

        conversation.leave(user)

        self.assertEqual(client.messages[0], {
            'topic': 'conversations:leave',
            'payload': {
                'id': conversation.id
            }
        })