3
# SchoolTool - common information systems platform for school administration
4
# Copyright (c) 2009 Shuttleworth Foundation
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
Unit tests for schooltool.intervention.generations.evolve2
24
from datetime import datetime
28
from zope.app.generations.utility import getRootFolder
30
from schooltool.generations.tests import ContextStub
31
from schooltool.intervention.generations.tests import provideAdapters
32
from schooltool.intervention.generations.evolve2 import evolve
33
from schooltool.intervention.intervention import InterventionMessage
34
from schooltool.intervention.intervention import InterventionGoal
37
def doctest_evolve2():
38
"""Evolution to generation 2.
40
First, we'll set up the app object:
43
>>> context = ContextStub()
44
>>> app = getRootFolder(context)
46
We'll set up our test with data that will be effected by running the
49
>>> root = app[u'schooltool.interventions'] = {}
50
>>> year = root['2009'] = {}
51
>>> student = year['jdoe'] = {}
53
>>> messages = student['messages'] = {}
54
>>> message1 = messages['1'] = InterventionMessage('', '', '')
55
>>> message1.created = datetime.now()
57
>>> goals = student['goals'] = {}
58
>>> goal1 = goals['1'] = InterventionGoal('', '', '', '', '', '', '',
60
>>> goal1.created = datetime.now()
62
Finally, we'll run the evolve script, testing the effected values before and
65
>>> message1.created.tzinfo is None
67
>>> goal1.created.tzinfo is None
72
>>> message1.created.tzinfo is None
74
>>> goal1.created.tzinfo is None
77
What if the intervention container doesn't exist yet in the
80
>>> context = ContextStub()
81
>>> app = getRootFolder(context)
88
return unittest.TestSuite([
89
doctest.DocTestSuite(optionflags=doctest.ELLIPSIS
90
| doctest.NORMALIZE_WHITESPACE
91
| doctest.REPORT_NDIFF
92
| doctest.REPORT_ONLY_FIRST_FAILURE),
95
if __name__ == '__main__':
96
unittest.main(defaultTest='test_suite')