Changeset 15427


Ignore:
Timestamp:
26 May 2019, 08:30:42 (6 years ago)
Author:
Henrik Bettermann
Message:

Construct fullname.

Location:
main/waeup.fceokene/trunk/src/waeup/fceokene
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.fceokene/trunk/src/waeup/fceokene/interswitch/tests.py

    r15303 r15427  
    6565        self.assertMatches('...Amount Authorized...',
    6666                           self.browser.contents)
    67         self.assertTrue(
    68             '<span>70450.0</span>' in self.browser.contents)
    6967        self.payment_url = self.browser.url
    7068        self.payment = self.student['payments'][self.value]
    7169
     70    def test_foo(self):
     71        '''Test method foo.
     72        '''
     73        return
    7274
    7375#    def callback_url(self, payment_url, resp, apprAmt):
  • main/waeup.fceokene/trunk/src/waeup/fceokene/utils/tests.py

    r8460 r15427  
    1818from waeup.kofa.testing import FunctionalTestCase
    1919from waeup.fceokene.testing import FunctionalLayer
     20from waeup.fceokene.utils.utils import CustomKofaUtils
    2021
    2122
     
    2425    layer = FunctionalLayer
    2526
    26     def test_foo(self):
    27         '''Test method foo.
    28         '''
    29         return
     27    def test_fullname(self):
     28        util = CustomKofaUtils()
     29        firstname = 'John'
     30        middlename = 'Z'
     31        lastname = 'Streep'
     32        self.assertEqual(
     33            util.fullname(firstname, lastname, middlename), 'John STREEP')
     34        firstname = 'J'
     35        self.assertEqual(
     36            util.fullname(firstname, lastname, middlename), 'STREEP')
     37        lastname = None
     38        self.assertEqual(
     39            util.fullname(firstname, lastname, middlename), '')
     40        firstname = 'John'
     41        self.assertEqual(
     42            util.fullname(firstname, lastname, middlename), 'John')
     43        firstname = 'J'
     44        middlename = 'Babatunde'
     45        lastname = 'Iron'
     46        self.assertEqual(
     47            util.fullname(firstname, lastname, middlename), 'Babatunde IRON')
  • main/waeup.fceokene/trunk/src/waeup/fceokene/utils/utils.py

    r14936 r15427  
    1818"""Customize general helper utilities for Kofa.
    1919"""
     20import string
    2021from copy import deepcopy
    2122from kofacustom.nigeria.utils.utils import NigeriaKofaUtils
     
    141142            return _('(visible after successful payment)')
    142143        return payment.p_item
     144
     145    def fullname(self, firstname, lastname, middlename=None):
     146        """Construct fullname.
     147        """
     148        try:
     149            lastname = lastname.upper()
     150        except AttributeError:
     151            pass
     152        # We remove single initial
     153        if firstname and len(firstname) == 1:
     154            firstname = ''
     155        if middlename and len(middlename) == 1:
     156            middlename = ''
     157        if lastname and len(lastname) == 1:
     158            lastname = ''
     159        # We construct givennames
     160        givennames = ''
     161        if middlename and firstname:
     162            givennames = '%s %s' % (firstname, middlename)
     163        elif firstname:
     164            givennames = firstname
     165        elif middlename:
     166            givennames = middlename
     167        givennames = string.capwords(
     168            givennames.replace('-', ' - ')).replace(' - ', '-')
     169        # We construct fullname
     170        fullname = ''
     171        if lastname and givennames:
     172            fullname = '%s %s' % (givennames, lastname)
     173        elif lastname:
     174            fullname = lastname
     175        elif givennames:
     176            fullname = givennames
     177        if '<' in fullname:
     178            return 'XXX'
     179        return fullname
Note: See TracChangeset for help on using the changeset viewer.