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.evolve4
27
from zope.app.testing import setup
28
from zope.component.hooks import setSite
29
from zope.interface import implements
30
from zope.site.folder import Folder
32
from schooltool.app.interfaces import ISchoolToolApplication
33
from schooltool.generations.tests import ContextStub
34
from schooltool.intervention.generations.evolve4 import evolve
35
from schooltool.intervention.interfaces import IInterventionGoal
38
class AppStub(Folder):
39
implements(ISchoolToolApplication)
42
class GoalStub(object):
43
implements(IInterventionGoal)
44
_persons_responsible = []
45
__dict__ = {'persons_responsible': ['jdoe']}
46
at_one_time_responsible = []
49
def doctest_evolve4():
50
"""Evolution to generation 4.
52
First, we'll set up the app object:
54
>>> context = ContextStub()
55
>>> context.root_folder['app'] = app = AppStub()
56
>>> app[u'schooltool.interventions'] = {}
57
>>> manager = setup.createSiteManager(app)
59
We'll set up our test with data that will be effected by running the
62
>>> root = app[u'schooltool.interventions']
63
>>> year = root['2009'] = {}
64
>>> student = year['jdoe'] = {}
66
>>> goals = student['goals'] = {}
67
>>> goal1 = goals['1'] = GoalStub()
69
Finally, we'll run the evolve script, testing the effected values before and
72
>>> goal1.__dict__['persons_responsible']
74
>>> goal1._persons_responsible
76
>>> goal1.at_one_time_responsible
81
>>> 'persons_responsible' in goal1.__dict__
83
>>> goal1._persons_responsible
85
>>> goal1.at_one_time_responsible
88
What if the intervention container doesn't exist yet in the
91
>>> context = ContextStub()
92
>>> context.root_folder['app'] = app = AppStub()
93
>>> manager = setup.createSiteManager(app)
100
setup.placefulSetUp()
104
setup.placefulTearDown()
109
return unittest.TestSuite([
110
doctest.DocTestSuite(setUp=setUp, tearDown=tearDown,
111
optionflags=doctest.ELLIPSIS
112
| doctest.NORMALIZE_WHITESPACE
113
| doctest.REPORT_NDIFF
114
| doctest.REPORT_ONLY_FIRST_FAILURE),
117
if __name__ == '__main__':
118
unittest.main(defaultTest='test_suite')