def test_that_job_returns_correct_feedback_subject(self): """Test if the job returns the correct feedback subject.""" with self.swap(constants, 'ENABLE_GENERALIZED_FEEDBACK_THREADS', False): feedback_services.create_thread( 'exploration', self.EXP_ID_1, 'unused_state_name', self.user_id, self.EXPECTED_THREAD_DICT1['subject'], self.EXPECTED_THREAD_DICT1['text']) feedback_services.create_thread( 'exploration', self.EXP_ID_1, 'unused_state_name', self.user_id, self.EXPECTED_THREAD_DICT2['subject'], self.EXPECTED_THREAD_DICT2['text']) feedback_services.create_thread( 'exploration', self.EXP_ID_1, 'unused_state_name', self.user_id, self.EXPECTED_THREAD_DICT3['subject'], self.EXPECTED_THREAD_DICT3['text']) feedback_services.create_thread( 'exploration', self.EXP_ID_1, 'unused_state_name', self.user_id, self.EXPECTED_THREAD_DICT4['subject'], self.EXPECTED_THREAD_DICT4['text']) feedback_services.create_thread( 'exploration', self.EXP_ID_1, 'unused_state_name', self.user_id, self.EXPECTED_THREAD_DICT5['subject'], self.EXPECTED_THREAD_DICT5['text']) feedback_services.create_thread( 'exploration', self.EXP_ID_1, 'unused_state_name', self.user_id, self.EXPECTED_THREAD_DICT6['subject'], self.EXPECTED_THREAD_DICT6['text']) feedback_services.create_thread( 'exploration', self.EXP_ID_1, 'unused_state_name', self.user_id, self.EXPECTED_THREAD_DICT7['subject'], self.EXPECTED_THREAD_DICT7['text']) threads_old = feedback_services.get_threads( 'exploration', self.EXP_ID_1) self._run_one_off_job() threads = feedback_services.get_threads('exploration', self.EXP_ID_1) self.assertEqual(threads[6].subject, u'a small summary') self.assertEqual(threads[5].subject, u'Some subject') self.assertEqual(threads[4].subject, u'It has to convert to a substring as it exceeds...') self.assertEqual( threads[3].subject, u'ItisjustaverylongsinglewordfortestinggetAbbreviate...') self.assertEqual(threads[2].subject, u'(Feedback from a learner)') self.assertEqual(threads[1].subject, u'Itisjustaverylongsinglewordfortesting') self.assertEqual(threads[0].subject, u'â, ??î or ôu🕧� n☁i✑💴++$-💯 ♓!🇪🚑🌚‼⁉4⃣od;...') self.assertEqual(threads[0].last_updated, threads_old[0].last_updated) self.assertEqual(threads[1].last_updated, threads_old[1].last_updated) self.assertEqual(threads[2].last_updated, threads_old[2].last_updated) self.assertEqual(threads[3].last_updated, threads_old[3].last_updated) self.assertEqual(threads[4].last_updated, threads_old[4].last_updated) self.assertEqual(threads[5].last_updated, threads_old[5].last_updated)
def test_get_threads_single_exploration(self): threads = feedback_services.get_threads('exploration', self.EXP_ID_1) self.assertEqual(len(threads), 0) feedback_services.create_thread( 'exploration', self.EXP_ID_1, None, self.EXPECTED_THREAD_DICT['subject'], 'not used here') threads = feedback_services.get_threads('exploration', self.EXP_ID_1) self.assertEqual(1, len(threads)) self.assertDictContainsSubset( self.EXPECTED_THREAD_DICT, threads[0].to_dict())
def test_get_threads_single_exploration(self): threads = feedback_services.get_threads(self.EXP_ID_1) self.assertEqual(len(threads), 0) feedback_services.create_thread( self.EXP_ID_1, self.EXPECTED_THREAD_DICT['state_name'], None, self.EXPECTED_THREAD_DICT['subject'], 'not used here') threads = feedback_services.get_threads(self.EXP_ID_1) self.assertEqual(1, len(threads)) self.assertDictContainsSubset(self.EXPECTED_THREAD_DICT, threads[0].to_dict())