def test_count_includes_only_approved_messages(self):
        # Create some new messages, one with each valid status
        sender = self.thread.first_message.sender
        thread = self.thread
        for status in MESSAGE_STATUSES:
            message = mommy.make(
                'connectmessages.Message', sender=sender, thread=thread)
            message.status = status[0]
            message.save()

        # Make sure we see them all
        self.assertEqual(
            Message.objects.with_deleted().filter(thread=thread).count(),
            len(MESSAGE_STATUSES) + 1
        )

        # Validate the returned count
        response = self.client.get(self.url)
        self.assertEqual(response.status_code, 200)
        content = json.loads(response.content)
        self.assertEqual(content['unread_count'], 2)
Test that rendering a Element without a docFactory attribute raises
dataset/ETHPy150Open ofa/connect/open_connect/connectmessages/tests/test_views.py/UnreadMessageCountViewTest.test_count_includes_only_approved_messages--crossover with--dataset/ETHPy150Open twisted/nevow/nevow/test/test_element.py/FlattenIntegrationTests.test_missingDocumentFactory