Changeset 12278


Ignore:
Timestamp:
21 Dec 2014, 08:45:24 (10 years ago)
Author:
uli
Message:

Update tests.

File:
1 edited

Legend:

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

    r12154 r12278  
    1919import re
    2020import unittest
     21from zope.component import getUtilitiesFor, getSiteManager
     22from zope.interface import implements
    2123from zope.interface.verify import verifyClass, verifyObject
    2224from waeup.ikoba.payments.interfaces import (
    2325    IPayment, STATE_UNPAID, STATE_PAID, STATE_FAILED,
     26    IPaymentGatewayService,
    2427    )
    25 from waeup.ikoba.payments.payment import Payment
     28from waeup.ikoba.payments.payment import Payment, get_payment_providers
     29
     30
     31class HelperTests(unittest.TestCase):
     32
     33    def tearDown(self):
     34        # unregister any IPaymentGatewayServices
     35        sm = getSiteManager(None)
     36        for name, util in getUtilitiesFor(
     37            IPaymentGatewayService):
     38            sm.unregisterUtility(util, name=name)
     39
     40    def test_get_payment_providers_no_providers(self):
     41        # we can get a dict of all payment providers
     42        result = get_payment_providers()
     43        assert isinstance(result, dict)
     44        assert result == {}
     45
     46    def test_get_payment_providers(self):
     47        # we get any payment providers registered
     48        sm = getSiteManager(None)
     49
     50        class FakeUtil(object):
     51            implements(IPaymentGatewayService)
     52
     53        fake_util = FakeUtil()
     54        sm.registerUtility(fake_util, name=u'some_name')
     55        result = get_payment_providers()
     56        assert isinstance(result, dict)
     57        assert result.keys() == ['some_name', ]
     58        assert result['some_name'] is fake_util
    2659
    2760
Note: See TracChangeset for help on using the changeset viewer.