def test_unicode_usernames(self, students): """ Test that students with unicode characters in their usernames are handled. """ for i, student in enumerate(students): self.create_student(username=student, email='student{0}@example.com'.format(i)) self.current_task = Mock() self.current_task.update_state = Mock() task_input = { 'features': [ 'id', 'username', 'name', 'email', 'language', 'location', 'year_of_birth', 'gender', 'level_of_education', 'mailing_address', 'goals' ] } with patch('instructor_task.tasks_helper._get_current_task' ) as mock_current_task: mock_current_task.return_value = self.current_task result = upload_students_csv(None, None, self.course.id, task_input, 'calculated') #This assertion simply confirms that the generation completed with no errors num_students = len(students) self.assertDictContainsSubset( { 'attempted': num_students, 'succeeded': num_students, 'failed': 0 }, result)
def test_delete_report(self): report_store = ReportStore.from_config() task_input = {'features': []} links = report_store.links_for(self.course.id) self.assertEquals(len(links), 0) with patch('instructor_task.tasks_helper._get_current_task'): upload_students_csv(None, None, self.course.id, task_input, 'calculated') links = report_store.links_for(self.course.id) self.assertEquals(len(links), 1) filename = links[0][0] report_store.delete_file(self.course.id, filename) links = report_store.links_for(self.course.id) self.assertEquals(len(links), 0)
def test_success(self): self.create_student('student', '*****@*****.**') task_input = {'features': []} with patch('instructor_task.tasks_helper._get_current_task'): result = upload_students_csv(None, None, self.course.id, task_input, 'calculated') report_store = ReportStore.from_config() links = report_store.links_for(self.course.id) self.assertEquals(len(links), 1) self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result)
def test_success(self): self.create_student('student', '*****@*****.**') task_input = {'features': []} with patch('instructor_task.tasks_helper._get_current_task'): result = upload_students_csv(None, None, self.course.id, task_input, 'calculated') report_store = ReportStore.from_config() links = report_store.links_for(self.course.id) self.assertEquals(len(links), 1) self.assertDictContainsSubset({'attempted': 1, 'succeeded': 1, 'failed': 0}, result)
def test_unicode_usernames(self, students): """ Test that students with unicode characters in their usernames are handled. """ for i, student in enumerate(students): self.create_student(username=student, email='student{0}@example.com'.format(i)) self.current_task = Mock() self.current_task.update_state = Mock() task_input = { 'features': [ 'id', 'username', 'name', 'email', 'language', 'location', 'year_of_birth', 'gender', 'level_of_education', 'mailing_address', 'goals' ] } with patch('instructor_task.tasks_helper._get_current_task') as mock_current_task: mock_current_task.return_value = self.current_task result = upload_students_csv(None, None, self.course.id, task_input, 'calculated') #This assertion simply confirms that the generation completed with no errors num_students = len(students) self.assertDictContainsSubset({'attempted': num_students, 'succeeded': num_students, 'failed': 0}, result)