def update_table_task(task_id, course_id): """Update progress_modules.""" update_state = partial( update_table_task.update_state, task_id=task_id, meta={"hostname": socket.gethostname(), "pid": os.getpid()} ) import time time.sleep(20) try: update_pgreport_table(course_id, update_state) except UserDoesNotExists as e: return "%s (%s)" % (e, course_id) return "Update complete!!! (%s)" % (course_id)
def test_update_pgreport_table(self): with patch('pgreport.views.ProgressModules') as pmock: update_pgreport_table(self.course.id) pmock.assert_any_call( count=6, display_name=self.problems[0].display_name, weight=None, standard_deviation=0.0, correct_map={}, median=0.0, due=None, submit_count=0, start=datetime.datetime(2030, 1, 1, 0, 0, tzinfo=UTC), location=self.problems[0].location, course_id=self.course.id, variance=0.0, student_answers={}, max_score=0.0, total_score=12.0, mean=0.0 ) with patch('pgreport.views.ProgressModules', side_effect=DatabaseError()): with self.assertRaises(DatabaseError): update_pgreport_table(self.course.id)