Skip to content

Commit

Permalink
Fix bug. Continue the loop processing even if any exception raises. o…
Browse files Browse the repository at this point in the history
  • Loading branch information
yokose-ks authored Apr 21, 2017
1 parent a953a5a commit a8ab139
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -645,10 +645,12 @@ def test_course_does_not_exist(self):
def test_error(self):
self.mock_aggregate.side_effect = Exception()
self._input_contract(self.single_spoc_video_contract, self.user)
self._input_contract(self.multiple_spoc_video_contract, self.user)

call_command('update_biz_playback_status', self.single_spoc_video_contract.id)
call_command('update_biz_playback_status')

self.assert_error(self.single_spoc_video_contract, self.single_spoc_video_course.id)
self.assert_error(self.multiple_spoc_video_contract, self.multiple_spoc_video_course.id)
self.mock_log.error.assert_called_once()

def _create_batch_status(self, contract, course, status, count=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,16 @@ def test_error(self):
self.mock_grade.side_effect = Exception()
self._input_contract(self.contract, self.user)

# Setup another contract
another_course = CourseFactory.create(org=self.gacco_organization.org_code, number='another_course', run='run')
another_contract = self._create_contract(detail_courses=[another_course])
self._input_contract(another_contract, self.user)

call_command('update_biz_score_status')

self.assert_error(self.contract, self.course1.id)
self.assert_error(self.contract, self.course2.id)
self.assert_error(another_contract, another_course.id)
self.mock_log.error.assert_called_once()

def _create_batch_status(self, contract, course, status, count=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,5 +263,5 @@ def handle(self, *args, **options):
log.error(u"Unexpected error occurred: {}".format(ex))
PlaybackBatchStatus.save_for_error(contract.id, course_key)

if error_flag:
raise CommandError("Error occurred while handling update_biz_playback_status command.")
if error_flag:
raise CommandError("Error occurred while handling update_biz_playback_status command.")
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ def handle(self, *args, **options):
log.error(u"Unexpected error occurred: {}".format(ex))
ScoreBatchStatus.save_for_error(contract.id, course_key)

if error_flag:
raise CommandError("Error occurred while handling update_biz_score_status command.")
if error_flag:
raise CommandError("Error occurred while handling update_biz_score_status command.")


def get_grade(course_key, student):
Expand Down

0 comments on commit a8ab139

Please sign in to comment.