source: WAeUP_SRP/base/skins/waeup_utilities/test_getAccommodationInfo.py @ 3258

Last change on this file since 3258 was 3087, checked in by joachim, 17 years ago

simplyfied logic for booking_allowed,
added test_getAccommodationInfo more testcases must be added

  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1## Script (Python) "test_getAccommodationInfo"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=
9##
10# $Id: test_getAccommodationInfo.py 3087 2008-02-02 11:04:55Z joachim $
11"""
12"""
13try:
14    from Products.zdb import set_trace
15except:
16    def set_trace():
17        pass
18
19mtool = context.portal_membership
20member = mtool.getAuthenticatedMember()
21if str(member) not in ('admin','joachim'):
22    return
23
24
25import logging
26import DateTime
27logger = logging.getLogger('Skins.test_getAccommodationInfo')
28from Products.AdvancedQuery import Eq, Between, Le,In
29aq_students = context.students_catalog.evalAdvancedQuery
30aq_portal = context.portal_catalog_real.evalAdvancedQuery
31students_folder = context.portal_url.getPortalObject().campus.students
32
33request = context.REQUEST
34session = request.SESSION
35response = request.RESPONSE
36setheader = request.RESPONSE.setHeader
37testcases = {}
38testcases['K817845'] = {'booking_allowed': False,
39                        'student_status': 'female_re',}
40testcases['E561916'] = {'booking_allowed': False,
41                        'student_status': 'female_fi',}
42ok_count = 0
43failed_count = 0
44logger.info("start test for %d students" % (len(testcases)))
45for student_id,expected in testcases.items():
46    logger.info("testing %s" % student_id)
47    info = context.getAccommodationInfo(student_id)
48    failed = False
49    for k in expected.keys():
50        if info[k] != expected[k]:
51            failed = True
52            break
53    if failed:
54        failed_count += 1
55        got = {}
56        for k in expected.keys():
57            got[k] = info[k]
58        logger.info("failed for %s expected %s got %s" % (student_id,
59                                                        expected,
60                                                        got
61                                                       ))
62    else:
63        logger.info("test %s OK" % student_id)
64        ok_count += 1
65
66logger.info("finished %d tests %d ok %d failed" % (len(testcases),ok_count,failed_count))
Note: See TracBrowser for help on using the repository browser.