def test_dispatch_authorized_user(self):
        user1 = self.create_user()
        self.client.login(username=user1.email, password='moo')
        group = mommy.make('groups.Group')
        user1.add_to_group(group.pk)
        response = self.client.post(
            reverse('create_group_message', kwargs={'group_id': group.pk}),
            {'subject': 'anything', 'text': '1275731253', 'group': group.pk}
        )
        self.assertRedirects(response, reverse('threads'))
        message = Message.objects.latest('pk')
        self.assertEqual(message.thread.group, group)
        self.assertNotIn('You don\'t have permission to post to this group.',
                         str(response.cookies))
Test the dispatch method for a user who is allowed to post
dataset/ETHPy150Open ofa/connect/open_connect/connectmessages/tests/test_views.py/TestSingleGroupMessageCreateView.test_dispatch_authorized_user