'Check to make sure an event is fired when a user responds to a thread.'

@patch('eventtracking.tracker.emit')
@patch('lms.lib.comment_client.utils.requests.request', autospec=True)
def test_response_event(self, mock_request, mock_emit):

    mock_request.return_value.status_code = 200
    self._set_mock_request_data(mock_request, {'closed': False, 'commentable_id': 'test_commentable_id', 'thread_id': 'test_thread_id'})
    request = RequestFactory().post('dummy_url', {'body': 'Test    comment', 'auto_subscribe': True})
    request.user = self.student
    request.view_name = 'create_comment'
    views.create_comment(request, course_id=unicode(self.course.id), thread_id='test_thread_id')
    (event_name, event) = mock_emit.call_args[0]
    self.assertEqual(event_name, 'edx.forum.response.created')
    self.assertEqual(event['body'], 'Test    comment')
    self.assertEqual(event['commentable_id'], 'test_commentable_id')
    self.assertEqual(event['user_forums_roles'], ['Student'])
    self.assertEqual(event['user_course_roles'], ['Wizard'])
    self.assertEqual(event['discussion']['id'], 'test_thread_id')
    self.assertEqual(event['options']['followed'], True)
