~ubuntu-branches/ubuntu/trusty/schooltool/trusty

« back to all changes in this revision

Viewing changes to src/schooltool/basicperson/tests/test_person.py

  • Committer: Gediminas Paulauskas
  • Date: 2013-10-10 16:53:33 UTC
  • mfrom: (1.1.27)
  • Revision ID: menesis@pov.lt-20131010165333-knsk88i2od7b8o70
Tags: 1:2.6.0-0ubuntu1
* New upstream release.
* debian/redis.conf: save redis databases less often.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import doctest
23
23
 
24
24
from zope.app.testing import setup
 
25
from zope.component import provideAdapter
 
26
from zope.interface import implements
 
27
 
 
28
from schooltool.app.interfaces import ISchoolToolApplication
 
29
from schooltool.app.interfaces import IApplicationPreferences
25
30
 
26
31
 
27
32
def doctest_BasicPerson():
36
41
         True
37
42
 
38
43
         >>> person.title
39
 
         'Johnson, Peter'
 
44
         'Peter Johnson'
40
45
 
41
46
    """
42
47
 
52
57
        >>> verifyObject(IPersonFactory, factory)
53
58
        True
54
59
 
55
 
        >>> for column in factory.columns():
56
 
        ...     print "%s, %s" % (column.name, column.title)
57
 
        first_name, First Name
58
 
        last_name, Last Name
59
 
 
60
 
        >>> factory.sortOn()
61
 
        (('last_name', False),)
 
60
        >>> class AppStub(object):
 
61
        ...     implements(ISchoolToolApplication, IApplicationPreferences)
 
62
        ...     def __init__(self):
 
63
        ...         self.name_sorting = 'last_name'
 
64
        >>> app = AppStub()
 
65
        >>> provideAdapter(lambda _: app,
 
66
        ...                adapts=(None, ), provides=ISchoolToolApplication)
 
67
 
 
68
        >>> for column in factory.columns():
 
69
        ...     print "%s, %s" % (column.name, column.title)
 
70
        last_name, Last Name
 
71
        first_name, First Name
 
72
 
 
73
        >>> factory.sortOn()
 
74
        (('last_name', False), ('first_name', False))
 
75
 
 
76
    If we change name sorting order, both the sort and column order changes:
 
77
 
 
78
        >>> app.name_sorting = 'first_name'
 
79
        >>> for column in factory.columns():
 
80
        ...     print "%s, %s" % (column.name, column.title)
 
81
        first_name, First Name
 
82
        last_name, Last Name
 
83
 
 
84
        >>> factory.sortOn()
 
85
        (('first_name', False), ('last_name', False))
62
86
 
63
87
    """
64
88
 
73
97
 
74
98
    The title of the manager user is set to "Administratorius" + system name:
75
99
 
76
 
        >>> manager = utility.createManagerUser("manager_username", "SchoolTool")
 
100
        >>> manager = utility.createManagerUser("manager_username")
77
101
        >>> manager.title
78
 
        'Administrator, SchoolTool'
 
102
        'Default Manager'
79
103
        >>> manager.username
80
104
        'manager_username'
81
105