'Tests if \'endorsed\' is True but \'endorsed_by\' is null, the api does not crash.
This is the case for some old/stale data in prod/stage environments.'

def test_profile_image_request_for_null_endorsed_by(self):

    self.register_get_user_response(self.user)
    thread = self.make_minimal_cs_thread({u'thread_type': u'question', u'endorsed_responses': [make_minimal_cs_comment({u'id': u'endorsed_comment', u'user_id': self.user.id, u'username': self.user.username, u'endorsed': True})], u'non_endorsed_resp_total': 0})
    self.register_get_thread_response(thread)
    self.create_profile_image(self.user, get_profile_image_storage())
    response = self.client.get(self.url, {u'thread_id': thread[u'id'], u'endorsed': True, u'requested_fields': u'profile_image'})
    self.assertEqual(response.status_code, 200)
    response_comments = json.loads(response.content)[u'results']
    for response_comment in response_comments:
        expected_author_profile_data = self.get_expected_user_profile(response_comment[u'author'])
        response_users = response_comment[u'users']
        self.assertEqual(expected_author_profile_data, response_users[response_comment[u'author']])
        self.assertNotIn(response_comment[u'endorsed_by'], response_users)
