Ignore:
Timestamp:
23 Mar 2012, 06:48:01 (13 years ago)
Author:
Henrik Bettermann
Message:

Disable external tests by default.

Reorganize tests slightly.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.custom/trunk/src/waeup/custom/etranzact/tests.py

    r7929 r7970  
    2020from waeup.custom.testing import FunctionalLayer
    2121
     22
     23# Also run tests that send requests to external servers?
     24#   If you enable this, please make sure the external services
     25#   do exist really and are not bothered by being spammed by a test programme.
     26EXTERNAL_TESTS = False
     27
     28def external_test(func):
     29    if not EXTERNAL_TESTS:
     30        myself = __file__
     31        if myself.endswith('.pyc'):
     32            myself = myself[:-2]
     33        print "WARNING: external tests are skipped!"
     34        print "WARNING: edit %s to enable them." % myself
     35        return
     36    return func
     37
    2238class EtranzactTests(StudentsFullSetup):
    2339    """Tests foreTranzact payment gateway.
     
    2844    CONFIRMATION_NO = '500856521315472785095'
    2945
     46    def test_dummy(self):
     47        return
     48
     49    @external_test
    3050    def test_etranzact_query_history(self):
    3151
  • main/waeup.custom/trunk/src/waeup/custom/interswitch/browser.py

    r7934 r7970  
    191191        student = self.context.getStudent()
    192192        query = self.request.form
    193         # Should be logged instead of printed
    194193        write_log_message(self,'callback received: %s' % query)
    195194
     
    214213        if self.context.r_amount_approved != total_amount_auth:
    215214            self.flash(_('Wrong amount'))
    216             write_log_message(self,'successful but wrong amount: %s' % self.context.p_id)
    217             self.context.p_state = 'failed'
    218             return
    219 
    220         # Add webservice validation
     215            write_log_message(
     216                self,'successful but wrong amount: %s' % self.context.p_id)
     217            self.context.p_state = 'failed'
     218            return
     219
    221220        try:
    222221            validation_list = get_SOAP_response(
    223222                PRODUCT_ID, self.context.p_id).split(':')
    224223            # Validation does not make sense yet since the query string
    225             # formats are conflicting. We are only printing the validation string,
    226             # nothing else.
    227             print validation_list
     224            # formats are conflicting. We are only printing the validation
     225            # string, nothing else.
     226            print 'WARNING: Webservice validation is not yet implemented'
     227            print 'validation list: %s' % validation_list
    228228        except:
    229229            print 'Connection to webservice failed.'
     230
     231        # Add webservice validation here
    230232
    231233        write_log_message(self,'valid callback: %s' % self.context.p_id)
    232234        self.context.p_state = 'paid'
    233235        self.context.payment_date = datetime.now()
    234 
    235236        actions_after_payment(student, self.context, self)
    236 
    237237        return
    238238
     
    271271            self.flash(_('Unsuccessful callback: ${a}',
    272272                mapping = {'a': wlist[1]}))
    273             write_log_message(self,'unsuccessful callback: %s' % self.context.p_id)
     273            write_log_message(
     274                self,'unsuccessful callback: %s' % self.context.p_id)
    274275            self.context.p_state = 'failed'
    275276            return
     
    282283        if self.context.r_amount_approved != total_amount_auth:
    283284            self.flash(_('Wrong amount'))
    284             write_log_message(self,'successful callback but wrong amount: %s' % self.context.p_id)
     285            write_log_message(
     286                self,'successful callback but wrong amount: %s'
     287                % self.context.p_id)
    285288            self.context.p_state = 'failed'
    286289            return
     
    288291        if wlist[4] != self.context.p_id:
    289292            self.flash(_('Wrong transaction id'))
    290             write_log_message(self,'successful callback but wrong transaction id: %s' % self.context.p_id)
     293            write_log_message(
     294                self,'successful callback but wrong transaction id: %s'
     295                % self.context.p_id)
    291296            self.context.p_state = 'failed'
    292297            return
  • main/waeup.custom/trunk/src/waeup/custom/interswitch/tests.py

    r7930 r7970  
    2020from waeup.custom.testing import FunctionalLayer
    2121
     22# Also run tests that send requests to external servers?
     23#   If you enable this, please make sure the external services
     24#   do exist really and are not bothered by being spammed by a test programme.
     25EXTERNAL_TESTS = False
     26
     27def external_test(func):
     28    if not EXTERNAL_TESTS:
     29        myself = __file__
     30        if myself.endswith('.pyc'):
     31            myself = myself[:-2]
     32        print "WARNING: external tests are skipped!"
     33        print "WARNING: edit %s to enable them." % myself
     34        return
     35    return func
     36
     37
    2238class InterswitchTests(StudentsFullSetup):
    2339    """Tests for the Interswitch payment gateway.
     
    2541
    2642    layer = FunctionalLayer
     43
     44    def setUp(self):
     45        super(InterswitchTests, self).setUp()
     46        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     47        self.browser.open(self.payments_student_path)
     48        IWorkflowState(self.student).setState('cleared')
     49        self.browser.open(self.payments_student_path + '/addop')
     50        self.browser.getControl("Create ticket").click()
     51        self.assertMatches('...ticket created...',
     52                           self.browser.contents)
     53        ctrl = self.browser.getControl(name='val_id')
     54        value = ctrl.options[0]
     55        self.browser.getLink(value).click()
     56        self.assertMatches('...Amount Authorized...',
     57                           self.browser.contents)
     58        self.payment_url = self.browser.url
     59
    2760
    2861    def callback_url(self, payment_url, resp, apprAmt):
     
    3770            '&url=http://xyz') % (resp, apprAmt)
    3871
    39     def test_callback(self):
     72    def test_interswitch_form(self):
    4073
    41         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    42         self.browser.open(self.payments_student_path)
    43         IWorkflowState(self.student).setState('cleared')
    44         self.browser.open(self.payments_student_path + '/addop')
    45         self.browser.getControl("Create ticket").click()
    46         self.assertMatches('...ticket created...',
    47                            self.browser.contents)
    48         ctrl = self.browser.getControl(name='val_id')
    49         value = ctrl.options[0]
    50         self.browser.getLink(value).click()
    51         self.assertMatches('...Amount Authorized...',
    52                            self.browser.contents)
    53         payment_url = self.browser.url
    54        
    5574        # Manager can access InterswitchForm
    5675        self.browser.getLink("CollegePAY", index=0).click()
     
    6180            self.browser.contents)
    6281
     82    @external_test
     83    def test_callback(self):
     84
    6385        # Manager can call callback manually
    64         self.browser.open(self.callback_url(payment_url, 'XX', '300'))
     86        self.browser.open(self.callback_url(self.payment_url, 'XX', '300'))
    6587        self.assertMatches('...Unsuccessful callback: Something went wrong...',
    6688                          self.browser.contents)
    6789        self.assertMatches('...Failed...',
    6890                           self.browser.contents)
    69         self.browser.open(payment_url + '/callback')
     91        self.browser.open(self.payment_url + '/callback')
    7092        self.assertMatches('...Unsuccessful callback: Incomplete query string...',
    7193                          self.browser.contents)
    7294        self.assertMatches('...Failed...',
    7395                           self.browser.contents)
    74         self.browser.open(self.callback_url(payment_url, '00', '300000'))
     96        self.browser.open(self.callback_url(self.payment_url, '00', '300000'))
    7597        self.assertMatches('...Wrong amount...',
    7698                          self.browser.contents)
    77         self.browser.open(self.callback_url(payment_url, '00', '4000000'))
     99        self.browser.open(self.callback_url(self.payment_url, '00', '4000000'))
    78100        self.assertMatches('...Valid callback received...',
    79101                          self.browser.contents)
    80102
     103    @external_test
    81104    def test_webservice(self):
    82105
    83         self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
    84         self.browser.open(self.payments_student_path)
    85         IWorkflowState(self.student).setState('cleared')
    86         self.browser.open(self.payments_student_path + '/addop')
    87         self.browser.getControl("Create ticket").click()
    88         self.assertMatches('...ticket created...',
    89                            self.browser.contents)
    90         ctrl = self.browser.getControl(name='val_id')
    91         value = ctrl.options[0]
    92         self.browser.getLink(value).click()
    93         self.assertMatches('...Amount Authorized...',
    94                            self.browser.contents)
    95         payment_url = self.browser.url
    96 
    97         self.browser.open(payment_url + '/request_webservice')
     106        self.browser.open(self.payment_url + '/request_webservice')
    98107        self.assertMatches('...Unsuccessful callback...',
    99108                          self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.