示例#1
0
    def check_refund(self):
        """Check that we have the refund permission."""
        test_id = 'refund'
        msg = loc('You have not setup permissions for us to check this '
                  'paypal account.')
        if not self.addon:
            # If there's no addon there's not even any point checking.
            return

        premium = self.addon.premium
        if not premium:
            self.state['permissions'] = False
            self.failure(test_id, msg)
            return

        token = premium.paypal_permissions_token
        if not token:
            self.state['permissions'] = False
            self.failure(test_id, msg)
            return

        try:
            status = paypal.check_permission(token, ['REFUND'])
            if not status:
                self.state['permissions'] = False
                self.failure(test_id, loc('No permission to do refunds.'))
            else:
                self.pass_(test_id)
        except paypal.PaypalError:
            self.state['permissions'] = False
            self.failure(test_id, msg)
            log.info('Refund permission check returned an error '
                     'for %s' % id, exc_info=True)
示例#2
0
 def test_check_permission_fail(self, _call):
     """
     `check_paypal_refund_permission` returns False if PayPal
     doesn't put 'REFUND' in the permissions response.
     """
     _call.return_value = {'scope(0)': 'HAM_SANDWICH'}
     assert not paypal.check_permission('foo', ['REFUND'])
示例#3
0
文件: test.py 项目: bebef1987/zamboni
 def test_check_permission_fail(self, _call):
     """
     `check_paypal_refund_permission` returns False if PayPal
     doesn't put 'REFUND' in the permissions response.
     """
     _call.return_value = {"scope(0)": "HAM_SANDWICH"}
     assert not paypal.check_permission(good_token, ["REFUND"])
示例#4
0
文件: test.py 项目: bebef1987/zamboni
 def test_check_permission(self, _call):
     """
     `check_paypal_refund_permission` returns True if PayPal
     puts 'REFUND' in the permissions response.
     """
     _call.return_value = {"scope(0)": "REFUND"}
     eq_(paypal.check_permission(good_token, ["REFUND"]), True)
示例#5
0
 def test_check_permission(self, _call):
     """
     `check_paypal_refund_permission` returns True if PayPal
     puts 'REFUND' in the permissions response.
     """
     _call.return_value = {'scope(0)': 'REFUND'}
     eq_(paypal.check_permission(good_token, ['REFUND']), True)
示例#6
0
 def test_check_permission(self, _call):
     """
     `check_paypal_refund_permission` returns True if PayPal
     puts 'REFUND' in the permissions response.
     """
     _call.return_value = {'scope(0)': 'REFUND'}
     eq_(paypal.check_permission('foo', ['REFUND']), True)
示例#7
0
 def test_check_permission_fail(self, _call):
     """
     `check_paypal_refund_permission` returns False if PayPal
     doesn't put 'REFUND' in the permissions response.
     """
     _call.return_value = {'scope(0)': 'HAM_SANDWICH'}
     assert not paypal.check_permission(good_token, ['REFUND'])
示例#8
0
文件: models.py 项目: hfeeki/zamboni
 def has_valid_permissions_token(self):
     """
     Have we got a valid permissions token by pinging PayPal. If you've got
     'should_ignore_paypal', then it will just happily return True.
     """
     if paypal.should_ignore_paypal():
         return True
     if not self.paypal_permissions_token:
         return False
     return paypal.check_permission(self.paypal_permissions_token, ["REFUND"])
示例#9
0
文件: models.py 项目: flyun/zamboni
 def has_valid_permissions_token(self):
     """
     Have we got a valid permissions token by pinging PayPal. If you've got
     'should_ignore_paypal', then it will just happily return True.
     """
     if paypal.should_ignore_paypal():
         return True
     if not self.paypal_permissions_token:
         return False
     return paypal.check_permission(self.paypal_permissions_token,
                                    ['REFUND'])
示例#10
0
 def test_check_permission_error(self, _call):
     _call.side_effect = paypal.PaypalError
     assert not paypal.check_permission(good_token, ['REFUND'])
示例#11
0
文件: test.py 项目: bebef1987/zamboni
 def test_get_permissions_subset(self, _call):
     _call.return_value = {"scope(0)": "REFUND", "scope(1)": "HAM"}
     eq_(paypal.check_permission(good_token, ["REFUND", "HAM"]), True)
     eq_(paypal.check_permission(good_token, ["REFUND", "JAM"]), False)
     eq_(paypal.check_permission(good_token, ["REFUND"]), True)
示例#12
0
文件: test.py 项目: bebef1987/zamboni
 def test_check_permission_settings(self, _call):
     settings.PAYPAL_PERMISSIONS_URL = ""
     assert not paypal.check_permission(good_token, ["REFUND"])
示例#13
0
文件: test.py 项目: bebef1987/zamboni
 def test_check_permission_error(self, _call):
     _call.side_effect = paypal.PaypalError
     assert not paypal.check_permission(good_token, ["REFUND"])
示例#14
0
 def test_get_permissions_subset(self, _call):
     _call.return_value = {'scope(0)': 'REFUND', 'scope(1)': 'HAM'}
     eq_(paypal.check_permission(good_token, ['REFUND', 'HAM']), True)
     eq_(paypal.check_permission(good_token, ['REFUND', 'JAM']), False)
     eq_(paypal.check_permission(good_token, ['REFUND']), True)
示例#15
0
 def test_check_permission_settings(self, _call):
     settings.PAYPAL_PERMISSIONS_URL = ''
     assert not paypal.check_permission(good_token, ['REFUND'])
示例#16
0
 def test_check_permission_settings(self, _call):
     settings.PAYPAL_PERMISSIONS_URL = ''
     assert not paypal.check_permission('oh-noes', ['REFUND'])
示例#17
0
 def test_check_permission_error(self, _call):
     _call.side_effect = paypal.PaypalError
     assert not paypal.check_permission('oh-noes', ['REFUND'])