def test_score_reset_user_conversion(self): """ Ensure that the score_reset handler properly calls the user_by_anonymous_id method to convert from an anonymized ID to a user object """ submissions_score_reset_handler(None, **SUBMISSION_RESET_KWARGS) self.get_user_mock.assert_called_once_with('anonymous_id')
def test_score_reset_user_conversion(self): """ Ensure that the score_reset handler properly calls the user_by_anonymous_id method to convert from an anonymized ID to a user object """ submissions_score_reset_handler(None, **SUBMISSION_RESET_KWARGS) self.get_user_mock.assert_called_once_with('anonymous_id')
def test_score_reset_bad_user(self): """ Ensure that, on receipt of a score_reset signal from the Submissions API that has an invalid user ID, the courseware model does not generate a signal. """ self.get_user_mock = self.setup_patch('courseware.models.user_by_anonymous_id', None) submissions_score_reset_handler(None, **SUBMISSION_RESET_KWARGS) self.signal_mock.assert_not_called()
def test_score_reset_bad_user(self): """ Ensure that, on receipt of a score_reset signal from the Submissions API that has an invalid user ID, the courseware model does not generate a signal. """ self.get_user_mock = self.setup_patch( 'courseware.models.user_by_anonymous_id', None) submissions_score_reset_handler(None, **SUBMISSION_RESET_KWARGS) self.signal_mock.assert_not_called()
def test_score_reset_missing_kwarg(self): """ Ensure that, on receipt of a score_reset signal from the Submissions API that does not have the correct kwargs, the courseware model does not generate a signal. """ for missing in SUBMISSION_RESET_KWARGS: kwargs = SUBMISSION_RESET_KWARGS.copy() del kwargs[missing] submissions_score_reset_handler(None, **kwargs) self.signal_mock.assert_not_called()
def test_score_reset_missing_kwarg(self): """ Ensure that, on receipt of a score_reset signal from the Submissions API that does not have the correct kwargs, the courseware model does not generate a signal. """ for missing in SUBMISSION_RESET_KWARGS: kwargs = SUBMISSION_RESET_KWARGS.copy() del kwargs[missing] submissions_score_reset_handler(None, **kwargs) self.signal_mock.assert_not_called()
def test_score_reset_signal_handler(self): """ Ensure that, on receipt of a score_reset signal from the Submissions API, the courseware model correctly converts it to a score_changed signal """ submissions_score_reset_handler(None, **SUBMISSION_RESET_KWARGS) expected_reset_kwargs = { 'sender': None, 'points_possible': 0, 'points_earned': 0, 'user_id': 42, 'course_id': 'CourseID', 'usage_id': 'i4x://org/course/usage/123456' } self.signal_mock.assert_called_once_with(**expected_reset_kwargs)
def test_score_reset_signal_handler(self): """ Ensure that, on receipt of a score_reset signal from the Submissions API, the courseware model correctly converts it to a score_changed signal """ submissions_score_reset_handler(None, **SUBMISSION_RESET_KWARGS) expected_reset_kwargs = { 'sender': None, 'points_possible': 0, 'points_earned': 0, 'user_id': 42, 'course_id': 'CourseID', 'usage_id': 'i4x://org/course/usage/123456' } self.signal_mock.assert_called_once_with(**expected_reset_kwargs)