예제 #1
0
 def test_escrow_throws_exception_if_not_AUTHORIZED(self):
     payment = Payment(**self.payment_arguments)
     for state in PAYMENT_STATES:
         if state == 'AUTHORIZED':
             continue
         payment.state = state
         with self.assertRaises(poundpay.payments.PaymentEscrowError):
             payment.escrow()
예제 #2
0
 def test_release_throws_exception_if_not_ESCROWED(self):
     payment = Payment(**self.payment_arguments)
     for state in PAYMENT_STATES:
         if state == 'ESCROWED':
             continue
         payment.state = state
         with self.assertRaises(poundpay.payments.PaymentReleaseError):
             payment.release()
예제 #3
0
 def test_release_throws_exception_if_not_ESCROWED(self):
     payment = Payment(**self.payment_arguments)
     for state in PAYMENT_STATES:
         if state == 'ESCROWED':
             continue
         payment.state = state
         with self.assertRaises(poundpay.payments.PaymentReleaseError):
             payment.release()
예제 #4
0
 def test_escrow_throws_exception_if_not_AUTHORIZED(self):
     payment = Payment(**self.payment_arguments)
     for state in PAYMENT_STATES:
         if state == 'AUTHORIZED':
             continue
         payment.state = state
         with self.assertRaises(poundpay.payments.PaymentEscrowError):
             payment.escrow()
예제 #5
0
    def test_escrow_sets_state_to_escrowed_and_issues_save(self):
        kwargs = self.payment_arguments
        kwargs['state'] = 'AUTHORIZED'
        payment = Payment(**kwargs)
        with mock.patch.object(Payment, 'save') as patched_save:
            payment.escrow()

        patched_save.assert_called_once_with()
        self.assertEqual(payment.state, 'ESCROWED')
예제 #6
0
    def test_release_sets_state_to_released_and_issues_save(self):
        kwargs = self.payment_arguments
        kwargs['state'] = 'ESCROWED'
        payment = Payment(**kwargs)
        with mock.patch.object(Payment, 'save') as patched_save:
            payment.release()

        patched_save.assert_called_once_with()
        self.assertEqual(payment.state, 'RELEASED')
예제 #7
0
    def test_escrow_sets_state_to_escrowed_and_issues_save(self):
        kwargs = self.payment_arguments
        kwargs['state'] = 'AUTHORIZED'
        payment = Payment(**kwargs)
        with mock.patch.object(Payment, 'save') as patched_save:
            payment.escrow()

        patched_save.assert_called_once_with()
        self.assertEqual(payment.state, 'ESCROWED')
예제 #8
0
    def test_release_sets_state_to_released_and_issues_save(self):
        kwargs = self.payment_arguments
        kwargs['state'] = 'ESCROWED'
        payment = Payment(**kwargs)
        with mock.patch.object(Payment, 'save') as patched_save:
            payment.release()

        patched_save.assert_called_once_with()
        self.assertEqual(payment.state, 'RELEASED')
예제 #9
0
 def test_cancel_throws_exception_if_not_ESCROWED(self):
     payment = Payment(**self.payment_arguments)
     applicable_states = (
         'CREATED',
         'AUTHORIZED',
         'ESCROWED',
     )
     for state in PAYMENT_STATES:
         if state in applicable_states:
             continue
         payment.state = state
         with self.assertRaises(poundpay.payments.PaymentCancelError) as e:
             payment.cancel()
         exc = e.exception
         self.assertEqual(
             exc.args[0],
             'Payment state is {}. Only {} payments may be {}'.format(
                 state, ', '.join(applicable_states), 'CANCELED'))
예제 #10
0
 def test_cancel_throws_exception_if_not_ESCROWED(self):
     payment = Payment(**self.payment_arguments)
     applicable_states = ('CREATED', 'AUTHORIZED', 'ESCROWED',)
     for state in PAYMENT_STATES:
         if state in applicable_states:
             continue
         payment.state = state
         with self.assertRaises(poundpay.payments.PaymentCancelError) as e:
             payment.cancel()
         exc = e.exception
         self.assertEqual(
             exc.args[0],
              'Payment state is {}. Only {} payments may be {}'.format(
                  state,
                  ', '.join(applicable_states),
                  'CANCELED'
                  )
             )