Changeset 8847 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 29 Jun 2012, 10:21:03 (12 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa/mandates
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/mandates/mandate.py
r8846 r8847 20 20 """ 21 21 import grok 22 import hashlib 22 23 from datetime import datetime, timedelta 24 from time import time 23 25 from grok import index 24 26 from waeup.kofa.interfaces import IUserAccount … … 32 34 grok.provides(IMandate) 33 35 34 def __init__(self, days=1 ):36 def __init__(self, days=1, category=None, mandate_id=None): 35 37 super(Mandate, self).__init__() 36 38 self.creation_date = datetime.utcnow() # offset-naive datetime 37 39 delta = timedelta(days=days) 38 40 self.expires = datetime.utcnow() + delta 39 self.mandate_id = None 40 self.category = None 41 if mandate_id is None: 42 timestamp = "%d" % int(time()*1000) 43 mandate_id = hashlib.md5(timestamp).hexdigest() 44 self.mandate_id = mandate_id 45 self.category = category 41 46 self.params = {} 42 47 return -
main/waeup.kofa/trunk/src/waeup/kofa/mandates/tests.py
r8846 r8847 85 85 # Add and execute a mandate with missing parameters. 86 86 mandate = Mandate() 87 mandate.mandate_id = '12345'88 87 mandate.category = 'student_password' 89 88 self.app['mandates'].addMandate(mandate) … … 92 91 # Add and execute an expired mandate. 93 92 mandate = Mandate(days=0) 94 mandate.mandate_id = '12345'95 93 mandate.category = 'student_password' 96 94 self.app['mandates'].addMandate(mandate) … … 99 97 # Ad and execute a perfect mandate 100 98 mandate = Mandate(days=0) 101 mandate.mandate_id = '12345'102 99 mandate.category = 'student_password' 103 100 mandate.params['student_id'] = student.student_id … … 114 111 # mandate1 is an old mandate which just expired. 115 112 mandate1 = Mandate(days=0) 116 mandate1.mandate_id = '12345'117 113 self.app['mandates'].addMandate(mandate1) 118 114 # mandate2 is a new mandate with default time delta. 119 mandate2 = Mandate() 120 mandate2.mandate_id = '23456' 115 mandate2 = Mandate(mandate_id='23456') 121 116 self.app['mandates'].addMandate(mandate2) 122 117 self.assertEqual(len(self.app['mandates'].keys()), 2)
Note: See TracChangeset for help on using the changeset viewer.