Ignore:
Timestamp:
11 Mar 2015, 17:08:34 (10 years ago)
Author:
uli
Message:

Restructure things a bit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/payments/tests/test_demo_provider.py

    r12712 r12734  
    1 import decimal
    21from zope.component import queryUtility
    32from zope.component.hooks import setSite
     
    109    )
    1110from waeup.ikoba.app import Company
    12 from waeup.ikoba.payments.payment import Payer, PaymentItem, Payee, Payment
     11from waeup.ikoba.payments.payment import Payer, Payee, Payment
    1312from waeup.ikoba.payments.demo_provider import (
    1413    DemoCreditcardPaymentService,
    1514    )
     15from waeup.ikoba.payments.tests.test_payment import FakePayer, FakePayable
    1616
    1717
     
    3535        # we can get payments from payment gateways
    3636        service = DemoCreditcardPaymentService()
    37         payer, payment_item, payee = Payer(), PaymentItem(), Payee()
     37        payer, payable, payee = Payer(), FakePayable(), Payee()
    3838        payer.payer_id = u'SOME_PAYER_ID'
    39         result = service.create_payment(payer, [], payee)
     39        result = service.create_payment(payer, payable, payee)
    4040        assert IPayment.providedBy(result)
    4141        assert result.gateway_service == u'demo_creditcard'
    4242        assert result.state == STATE_UNPAID
    43         assert len(result) == 0  # no items stored
    44 
    45     def test_create_payment_honors_payment_item(self):
    46         # we inspect payment items and take their values
    47         service = DemoCreditcardPaymentService()
    48         payer, payment_item, payee = Payer(), PaymentItem(), Payee()
    49         payment_item.item_id = u'SOME_ITEM_ID'
    50         payer.payer_id = u'SOME_PAYER_ID'
    51         payment_item.amount = decimal.Decimal("300.99")
    52         result = service.create_payment(payer, [payment_item], payee)
    53         self.assertEqual(result.amount, payment_item.amount)
    54         assert len(result) == 1
    5543
    5644    def test_create_payment_honors_payer(self):
    5745        # we inspect payers when creating their payments
    5846        service = DemoCreditcardPaymentService()
    59         payer, payment_item, payee = Payer(), PaymentItem(), Payee()
    60         payment_item.item_id = u'SOME_ITEM_ID'
     47        payer, payable, payee = Payer(), FakePayable(), Payee()
    6148        payer.payer_id = u'SOME_PAYER_ID'
    62         result = service.create_payment(payer, [payment_item], payee)
     49        result = service.create_payment(payer, payable, payee)
    6350        assert result.payer_id == payer.payer_id
    6451
     
    7865        # we are redirected to 'index' in the beginning
    7966        service = DemoCreditcardPaymentService()
    80         p1 = Payment()
     67        p1 = Payment(FakePayer(), FakePayable())
    8168        self.app['payments']['1'] = p1
    8269        p_id = p1.payment_id
Note: See TracChangeset for help on using the changeset viewer.