'Tests thread has user profile image details if called in requested_fields'

def test_profile_image_requested_field(self):

    user_2 = UserFactory.create(password=self.password)
    user_2.profile.year_of_birth = 1970
    user_2.profile.save()
    source_threads = [self.create_source_thread(), self.create_source_thread({u'user_id': str(user_2.id), u'username': user_2.username})]
    self.register_get_user_response(self.user, upvoted_ids=[u'test_thread'])
    self.register_get_threads_response(source_threads, page=1, num_pages=1)
    self.create_profile_image(self.user, get_profile_image_storage())
    self.create_profile_image(user_2, get_profile_image_storage())
    response = self.client.get(self.url, {u'course_id': unicode(self.course.id), u'requested_fields': u'profile_image'})
    self.assertEqual(response.status_code, 200)
    response_threads = json.loads(response.content)[u'results']
    for response_thread in response_threads:
        expected_profile_data = self.get_expected_user_profile(response_thread[u'author'])
        response_users = response_thread[u'users']
        self.assertEqual(expected_profile_data, response_users[response_thread[u'author']])
