コード例 #1
0
 def test_not_authorized_warning(self, mock_log_warning):
     """
     Ensure that expected authorization issues are logged as warnings.
     """
     with mock_create_refund(status=403):
         refund_seat(self.course_enrollment, UserFactory())
         self.assertTrue(mock_log_warning.called)
コード例 #2
0
 def test_not_authorized_warning(self, mock_log_warning):
     """
     Ensure that expected authorization issues are logged as warnings.
     """
     with mock_create_refund(status=403):
         refund_seat(self.course_enrollment, UserFactory())
         self.assertTrue(mock_log_warning.called)
コード例 #3
0
 def test_notification_no_refund(self, mock_send_notification):
     """
     Ensure the notification function is NOT triggered when no refunds are
     initiated
     """
     with mock_create_refund(status=200, response=[]):
         self.send_signal()
         self.assertFalse(mock_send_notification.called)
コード例 #4
0
 def test_notification(self, mock_send_notification):
     """
     Ensure the notification function is triggered when refunds are
     initiated
     """
     with mock_create_refund(status=200, response=[1, 2, 3]):
         self.send_signal()
         self.assertTrue(mock_send_notification.called)
コード例 #5
0
 def test_error_logging(self, mock_log_exception):
     """
     Ensure that unexpected Exceptions are logged as errors (but do not
     break program flow).
     """
     with mock_create_refund(status=500):
         self.send_signal()
         self.assertTrue(mock_log_exception.called)
コード例 #6
0
ファイル: test_signals.py プロジェクト: dehamzah/edx-platform
 def test_error_logging(self, mock_log_exception):
     """
     Ensure that unexpected Exceptions are logged as errors (but do not
     break program flow).
     """
     with mock_create_refund(status=500):
         self.send_signal()
         self.assertTrue(mock_log_exception.called)
コード例 #7
0
ファイル: test_signals.py プロジェクト: dehamzah/edx-platform
 def test_notification_no_refund(self, mock_send_notification):
     """
     Ensure the notification function is NOT triggered when no refunds are
     initiated
     """
     with mock_create_refund(status=200, response=[]):
         self.send_signal()
         self.assertFalse(mock_send_notification.called)
コード例 #8
0
 def test_notification(self, mock_send_notification):
     """
     Ensure the notification function is triggered when refunds are
     initiated
     """
     with mock_create_refund(status=200, response=[1, 2, 3]):
         self.send_signal()
         self.assertTrue(mock_send_notification.called)
コード例 #9
0
ファイル: test_signals.py プロジェクト: dehamzah/edx-platform
 def test_notification_error(self, mock_log_warning, mock_send_notification):
     """
     Ensure an error occuring during notification does not break program
     flow, but a warning is logged.
     """
     with mock_create_refund(status=200, response=[1, 2, 3]):
         self.send_signal()
         self.assertTrue(mock_send_notification.called)
         self.assertTrue(mock_log_warning.called)
コード例 #10
0
 def test_notification_error(self, mock_log_warning, mock_send_notification):
     """
     Ensure an error occuring during notification does not break program
     flow, but a warning is logged.
     """
     with mock_create_refund(status=200, response=[1, 2, 3]):
         self.send_signal()
         self.assertTrue(mock_send_notification.called)
         self.assertTrue(mock_log_warning.called)
コード例 #11
0
ファイル: test_signals.py プロジェクト: dehamzah/edx-platform
 def test_notification_not_verified(self, mode, mock_send_notification):
     """
     Ensure the notification function is NOT triggered when the
     unenrollment is for any mode other than verified (i.e. any mode other
     than one for which refunds are presently supported).  See the
     TODO associated with XCOM-371 in the signals module in the commerce
     package for more information.
     """
     self.course_enrollment.mode = mode
     with mock_create_refund(status=200, response=[1, 2, 3]):
         self.send_signal()
         self.assertFalse(mock_send_notification.called)
コード例 #12
0
ファイル: test_signals.py プロジェクト: dehamzah/edx-platform
    def test_notification_if_automatic_approval_disabled(self, mock_send_notification):
        """
        Ensure the notification is always sent if the automatic approval functionality is disabled.
        """
        refund_id = 1
        self.config.enable_automatic_refund_approval = False
        self.config.save()

        with mock_create_refund(status=201, response=[refund_id]):
            self.send_signal()
            self.assertTrue(mock_send_notification.called)
            mock_send_notification.assert_called_with(self.course_enrollment, [refund_id])
コード例 #13
0
 def test_notification_not_verified(self, mode, mock_send_notification):
     """
     Ensure the notification function is NOT triggered when the
     unenrollment is for any mode other than verified (i.e. any mode other
     than one for which refunds are presently supported).  See the
     TODO associated with XCOM-371 in the signals module in the commerce
     package for more information.
     """
     self.course_enrollment.mode = mode
     with mock_create_refund(status=200, response=[1, 2, 3]):
         self.send_signal()
         self.assertFalse(mock_send_notification.called)
コード例 #14
0
ファイル: test_signals.py プロジェクト: dehamzah/edx-platform
    def test_no_notification_after_approval(self, mock_send_notification):
        """
        Ensure the notification function is triggered when refunds are initiated, and cannot be automatically approved.
        """
        refund_id = 1

        with mock_create_refund(status=201, response=[refund_id]):
            with mock_process_refund(refund_id, reset_on_exit=False):
                self.send_signal()
                self.assertFalse(mock_send_notification.called)

                last_request = httpretty.last_request()
                self.assertDictEqual(json.loads(last_request.body), {'action': 'approve_payment_only'})
コード例 #15
0
ファイル: test_signals.py プロジェクト: dehamzah/edx-platform
    def test_notification_when_approval_fails(self, mock_send_notification):
        """
        Ensure the notification function is triggered when refunds are initiated, and cannot be automatically approved.
        """
        refund_id = 1
        failed_refund_id = 2

        with mock_create_refund(status=201, response=[refund_id, failed_refund_id]):
            with mock_process_refund(refund_id, reset_on_exit=False):
                with mock_process_refund(failed_refund_id, status=500, reset_on_exit=False):
                    self.send_signal()
                    self.assertTrue(mock_send_notification.called)
                    mock_send_notification.assert_called_with(self.course_enrollment, [failed_refund_id])
コード例 #16
0
    def test_notification_if_automatic_approval_disabled(
            self, mock_send_notification):
        """
        Ensure the notification is always sent if the automatic approval functionality is disabled.
        """
        refund_id = 1
        self.config.enable_automatic_refund_approval = False
        self.config.save()

        with mock_create_refund(status=201, response=[refund_id]):
            self.send_signal()
            self.assertTrue(mock_send_notification.called)
            mock_send_notification.assert_called_with(self.course_enrollment,
                                                      [refund_id])
コード例 #17
0
    def test_no_notification_after_approval(self, mock_send_notification):
        """
        Ensure the notification function is triggered when refunds are initiated, and cannot be automatically approved.
        """
        refund_id = 1

        with mock_create_refund(status=201, response=[refund_id]):
            with mock_process_refund(refund_id, reset_on_exit=False):
                self.send_signal()
                self.assertFalse(mock_send_notification.called)

                last_request = httpretty.last_request()
                self.assertDictEqual(json.loads(last_request.body),
                                     {'action': 'approve_payment_only'})
コード例 #18
0
    def test_notification_when_approval_fails(self, mock_send_notification):
        """
        Ensure the notification function is triggered when refunds are initiated, and cannot be automatically approved.
        """
        refund_id = 1
        failed_refund_id = 2

        with mock_create_refund(status=201,
                                response=[refund_id, failed_refund_id]):
            with mock_process_refund(refund_id, reset_on_exit=False):
                with mock_process_refund(failed_refund_id,
                                         status=500,
                                         reset_on_exit=False):
                    self.send_signal()
                    self.assertTrue(mock_send_notification.called)
                    mock_send_notification.assert_called_with(
                        self.course_enrollment, [failed_refund_id])