def test_regular_user_can_direct_message_staff(self):
        sender = self.create_user()
        staff_member = self.create_user(is_staff=True)
        self.login(sender)

        # POST a fake message directed at a staff member
        response = self.client.post(
            reverse('create_direct_message',
                    kwargs={'user_uuid': staff_member.uuid}),
            {'text': 'hello', 'subject': 'quick dm'}
        )

        # Confirm the user is redirected to the "threads" page
        self.assertRedirects(response, reverse('threads'))

        # Confirm that there is not a permission denied message
        self.assertNotIn(
            'You don\'t have permission to direct message {user}'.format(
                user=staff_member),
            str(response.cookies)
        )

        # Confirm that the staff member now has a message
        self.assertEqual(
            UserThread.objects.filter(
                user=staff_member,
                thread__first_message__sender=sender).count(),
            1
        )
Test that regular users can direct message staff
dataset/ETHPy150Open ofa/connect/open_connect/connectmessages/tests/test_views.py/DirectMessageCreateViewTest.test_regular_user_can_direct_message_staff