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 | """ |
---|
13 | try: |
---|
14 | from Products.zdb import set_trace |
---|
15 | except: |
---|
16 | def set_trace(): |
---|
17 | pass |
---|
18 | |
---|
19 | mtool = context.portal_membership |
---|
20 | member = mtool.getAuthenticatedMember() |
---|
21 | if str(member) not in ('admin','joachim'): |
---|
22 | return |
---|
23 | |
---|
24 | |
---|
25 | import logging |
---|
26 | import DateTime |
---|
27 | logger = logging.getLogger('Skins.test_getAccommodationInfo') |
---|
28 | from Products.AdvancedQuery import Eq, Between, Le,In |
---|
29 | aq_students = context.students_catalog.evalAdvancedQuery |
---|
30 | aq_portal = context.portal_catalog_real.evalAdvancedQuery |
---|
31 | students_folder = context.portal_url.getPortalObject().campus.students |
---|
32 | |
---|
33 | request = context.REQUEST |
---|
34 | session = request.SESSION |
---|
35 | response = request.RESPONSE |
---|
36 | setheader = request.RESPONSE.setHeader |
---|
37 | testcases = {} |
---|
38 | testcases['K817845'] = {'booking_allowed': False, |
---|
39 | 'student_status': 'female_re',} |
---|
40 | testcases['E561916'] = {'booking_allowed': False, |
---|
41 | 'student_status': 'female_fi',} |
---|
42 | ok_count = 0 |
---|
43 | failed_count = 0 |
---|
44 | logger.info("start test for %d students" % (len(testcases))) |
---|
45 | for 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 | |
---|
66 | logger.info("finished %d tests %d ok %d failed" % (len(testcases),ok_count,failed_count)) |
---|