

def test_author_ids_are_handled_correctly(self):
    'Test that author ids are converted into author usernames\n        and that anonymous authors are handled correctly.\n        '
    with self.swap(user_jobs_continuous.DashboardRecentUpdatesAggregator, 'get_recent_notifications', self._get_recent_notifications_mock_by_viewer):
        self.login(self.VIEWER_EMAIL)
        response = self.get_json(self.DASHBOARD_DATA_URL)
        self.assertEqual(len(response['recent_notifications']), 1)
        self.assertEqual(response['recent_notifications'][0]['author_username'], self.VIEWER_USERNAME)
        self.assertNotIn('author_id', response['recent_notifications'][0])
    with self.swap(user_jobs_continuous.DashboardRecentUpdatesAggregator, 'get_recent_notifications', self._get_recent_notifications_mock_by_anonymous_user):
        self.login(response.VIEWER_EMAIL)
        response = self.get_json(self.DASHBOARD_DATA_URL)
        self.assertEqual(len(response['recent_notifications']), 1)
        self.assertEqual(response['recent_notifications'][0]['author_username'], '')
        self.assertNotIn('author_id', response['recent_notifications'][0])

dataset/ETHPy150Open oppia/oppia/core/controllers/home_test.py NotificationsDashboardHandlerTest.test_author_ids_are_handled_correctly/VarMisuse@123/249 `self`->`response`