~ubuntu-branches/ubuntu/raring/schooltool.intervention/raring

« back to all changes in this revision

Viewing changes to src/schooltool/intervention/generations/tests/test_evolve5.py

  • Committer: Gediminas Paulauskas
  • Date: 2011-09-19 16:56:45 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: menesis@pov.lt-20110919165645-718diuud5tc4mjsx
Tags: 0.5.0-0ubuntu1
* New upstream release.
* debian/rules: move gradebook to Suggests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# coding=UTF8
2
 
#
3
 
# SchoolTool - common information systems platform for school administration
4
 
# Copyright (c) 2009 Shuttleworth Foundation
5
 
#
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.
10
 
#
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.
15
 
#
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
19
 
#
20
 
"""
21
 
Unit tests for schooltool.intervention.generations.evolve5
22
 
"""
23
 
 
24
 
import unittest
25
 
import doctest
26
 
 
27
 
from zope.app.testing import setup
28
 
from zope.catalog.interfaces import ICatalog
29
 
from zope.component import queryUtility, provideUtility
30
 
from zope.component.hooks import getSite, setSite
31
 
from zope.interface import implements
32
 
from zope.intid import IntIds
33
 
from zope.intid.interfaces import IIntIds
34
 
from zope.site.folder import Folder
35
 
 
36
 
from schooltool.app.interfaces import ISchoolToolApplication
37
 
from schooltool.generations.tests import ContextStub
38
 
from schooltool.intervention.generations.evolve5 import evolve
39
 
 
40
 
 
41
 
class AppStub(Folder):
42
 
    implements(ISchoolToolApplication)
43
 
 
44
 
 
45
 
def doctest_evolve5():
46
 
    """Evolution to generation 5.
47
 
 
48
 
    We'll need int ids.
49
 
 
50
 
        >>> provideUtility(IntIds(), IIntIds)
51
 
 
52
 
    We need an app.
53
 
 
54
 
        >>> context = ContextStub()
55
 
        >>> context.root_folder['app'] = app = AppStub()
56
 
        >>> manager = setup.createSiteManager(app)
57
 
 
58
 
    Let's evolve now.
59
 
 
60
 
        >>> evolve(context)
61
 
 
62
 
    Site was restored after evolution.
63
 
 
64
 
        >>> print getSite()
65
 
        None
66
 
 
67
 
    Contact catalog was registered for ISchoolToolApplication sites.
68
 
 
69
 
        >>> catalog = queryUtility(ICatalog, 'schooltool.intervention')
70
 
        >>> print catalog
71
 
        None
72
 
 
73
 
        >>> setSite(app)
74
 
 
75
 
        >>> catalog = queryUtility(ICatalog, 'schooltool.intervention')
76
 
        >>> catalog
77
 
        <zc.catalog.extentcatalog.Catalog object ...>
78
 
 
79
 
    Catalog indexes were set up properly.
80
 
 
81
 
        >>> sorted(i.__name__ for i in catalog.values())
82
 
        [u'created', u'first_name', u'intervention_type', u'last_name',
83
 
         u'persons_responsible', u'schoolYearId']
84
 
 
85
 
    """
86
 
 
87
 
 
88
 
def setUp(test):
89
 
    setup.placefulSetUp()
90
 
    setSite()
91
 
 
92
 
def tearDown(test):
93
 
    setup.placefulTearDown()
94
 
    setSite()
95
 
 
96
 
 
97
 
def test_suite():
98
 
    return unittest.TestSuite([
99
 
        doctest.DocTestSuite(setUp=setUp, tearDown=tearDown,
100
 
                             optionflags=doctest.ELLIPSIS
101
 
                             | doctest.NORMALIZE_WHITESPACE
102
 
                             | doctest.REPORT_NDIFF
103
 
                             | doctest.REPORT_ONLY_FIRST_FAILURE),
104
 
        ])
105
 
 
106
 
if __name__ == '__main__':
107
 
    unittest.main(defaultTest='test_suite')
108