~ubuntu-branches/ubuntu/trusty/schooltool.lyceum.journal/trusty-proposed

« back to all changes in this revision

Viewing changes to src/schooltool/lyceum/journal/stests/default_section.txt

  • Committer: Package Import Robot
  • Author(s): Gediminas Paulauskas
  • Date: 2013-11-24 22:30:00 UTC
  • mfrom: (26.1.1 schooltool.lyceum.journal)
  • Revision ID: package-import@ubuntu.com-20131124223000-ejedim48x8z2xb2o
Tags: 2.6.1-0ubuntu1
New upstream bugfix release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Default section tests
 
2
=====================
 
3
 
 
4
When a person has been added to multiple sections in different school
 
5
years, the default section when they click the Journal tab should be
 
6
in the active school year. If possible the section should also be in
 
7
the current term.
 
8
 
 
9
Some helpers (XXX: duplicated and modified from gradebook's
 
10
navigation.txt):
 
11
 
 
12
    >>> # FORMATTERS
 
13
    >>> def format_option(option, selected):
 
14
    ...     return ['%s', '*%s*'][selected] % option
 
15
    >>> def format_navigator(header, option):
 
16
    ...     return '%s: %s' % (header, option)
 
17
    >>> def format_tab(tab):
 
18
    ...     text = tab.query.tag('a').get_attribute('title')
 
19
    ...     active = tab.get_attribute('class') in ('active',)
 
20
    ...     return ['%s', '*%s*'][active] % text
 
21
 
 
22
    >>> # GETTERS
 
23
    >>> def get_navigators(browser):
 
24
    ...     return browser.query_all.css('.refine .content')[1:4]
 
25
    >>> def get_section_navigator(browser):
 
26
    ...     return get_navigators(browser)[0]
 
27
    >>> def get_term_navigator(browser):
 
28
    ...     return get_navigators(browser)[1]
 
29
    >>> def get_schoolyear_navigator(browser):
 
30
    ...     return get_navigators(browser)[2]
 
31
    >>> def get_navigator_header(navigator):
 
32
    ...     return navigator.query.css('.header').text
 
33
    >>> def get_navigator_options(navigator):
 
34
    ...     result = []
 
35
    ...     for option in navigator.query_all.tag('option'):
 
36
    ...         result.append((option.text, option.is_selected()))
 
37
    ...     return result
 
38
    >>> def get_navigator_selected_option(navigator):
 
39
    ...     options = get_navigator_options(navigator)
 
40
    ...     text, selected = filter(lambda x:x[-1], options)[0]
 
41
    ...     return text
 
42
    >>> def get_tabs(browser):
 
43
    ...     return browser.query_all.css('.third-nav li')  
 
44
 
 
45
    >>> # PRINTERS
 
46
    >>> def print_navigator_options(navigator):
 
47
    ...     for text, selected in get_navigator_options(navigator):
 
48
    ...         print format_option(text, selected)
 
49
    >>> def print_navigator(navigator):
 
50
    ...     header = get_navigator_header(navigator)
 
51
    ...     selected = get_navigator_selected_option(navigator)
 
52
    ...     print format_navigator(header, selected)
 
53
    >>> def print_navigators(browser):
 
54
    ...     for navigator in get_navigators(browser):
 
55
    ...         print_navigator(navigator)
 
56
    >>> def print_section_navigator(browser):
 
57
    ...     navigator = get_section_navigator(browser)
 
58
    ...     print_navigator_options(navigator)
 
59
    >>> def print_term_navigator(browser):
 
60
    ...     navigator = get_term_navigator(browser)
 
61
    ...     print_navigator_options(navigator)
 
62
    >>> def print_schoolyear_navigator(browser):
 
63
    ...     navigator = get_schoolyear_navigator(browser)
 
64
    ...     print_navigator_options(navigator)
 
65
    >>> def print_tabs(browser):
 
66
    ...     for tab in get_tabs(browser):
 
67
    ...         print format_tab(tab)
 
68
 
 
69
Log in as manager:
 
70
 
 
71
    >>> manager = browsers.manager
 
72
    >>> manager.ui.login('manager', 'schooltool')
 
73
 
 
74
Set up several school years:
 
75
 
 
76
    >>> manager.ui.schoolyear.add('2011', '2011-01-01', '2011-12-31')
 
77
    >>> manager.ui.schoolyear.add('2012', '2012-01-01', '2012-12-31')
 
78
    >>> manager.ui.schoolyear.add('2013', '2013-01-01', '2013-12-31')
 
79
 
 
80
Currently, the first school year added is the active one.
 
81
 
 
82
Add a couple of terms in each year:
 
83
 
 
84
    >>> manager.ui.term.add('2011', 'S1', '2011-01-01', '2011-06-30')
 
85
    >>> manager.ui.term.add('2011', 'S2', '2011-07-01', '2011-12-31')
 
86
 
 
87
    >>> manager.ui.term.add('2012', 'S1', '2012-01-01', '2012-06-30')
 
88
    >>> manager.ui.term.add('2012', 'S2', '2012-07-01', '2012-12-31')
 
89
 
 
90
And some persons:
 
91
 
 
92
    >>> manager.ui.person.add('Tom', 'Hoffman', 'tom', 'pwd')
 
93
    >>> manager.ui.person.add('Jeff', 'Elkner', 'jeff', 'pwd')
 
94
    >>> manager.ui.person.add('David', 'Welsh', 'david', 'pwd')
 
95
    >>> manager.ui.person.add('Camila', 'Cerna', 'camila', 'pwd')
 
96
    >>> manager.ui.person.add('Mario', 'Tejada', 'mario', 'pwd')
 
97
    >>> manager.ui.person.add('Nestor', 'Guzman', 'nestor', 'pwd')
 
98
 
 
99
We're going to add different courses for each year:
 
100
 
 
101
    >>> manager.ui.course.add('2011', 'Math')
 
102
    >>> manager.ui.course.add('2012', 'Baseball')
 
103
    >>> manager.ui.course.add('2013', 'Soccer')
 
104
 
 
105
Now sections for each course:
 
106
 
 
107
    >>> manager.ui.section.add('2011', 'S1', 'Math', ends='S2')
 
108
    >>> manager.ui.section.instructors.add('2011', 'S1', 'Math (1)',
 
109
    ...                                    ['tom', 'jeff', 'david'])
 
110
    >>> manager.ui.section.students.add('2011', 'S1', 'Math (1)',
 
111
    ...                                 ['camila', 'mario'])
 
112
 
 
113
    >>> manager.ui.section.add('2012', 'S1', 'Baseball', ends='S2')
 
114
    >>> manager.ui.section.instructors.add('2012', 'S1', 'Baseball (1)',
 
115
    ...                                    ['tom', 'jeff'])
 
116
    >>> manager.ui.section.students.add('2012', 'S1', 'Baseball (1)',
 
117
    ...                                 ['mario'])
 
118
 
 
119
After Tom, Jeff and David have been added as instructors to sections
 
120
in the two years, we'll activate the 2012 year:
 
121
 
 
122
    >>> manager.open('http://localhost/schoolyears')
 
123
    >>> manager.query.link('Activate New Year').click()
 
124
    >>> manager.query.css('input[value="2012"]').click()
 
125
    >>> manager.query.name('SUBMIT').click()
 
126
 
 
127
We'll check that the first time Tom logs in he's redirected to a 2012
 
128
section:
 
129
 
 
130
    >>> tom = browsers.tom
 
131
    >>> tom.ui.login('tom', 'pwd')
 
132
    >>> tom.query.link('Journal').click()
 
133
 
 
134
    >>> print_navigators(tom)
 
135
    Section: Baseball (1)
 
136
    Term: S1
 
137
    Year: 2012
 
138
 
 
139
Now, we'll set the current term to be S2 in 2012:
 
140
 
 
141
    >>> manager.open('http://localhost/time?value=2012-08-01')
 
142
 
 
143
And get Jeff to log in for the first time. He should be redirected
 
144
to the Soccer S2 section:
 
145
 
 
146
    >>> jeff = browsers.jeff
 
147
    >>> jeff.ui.login('jeff', 'pwd')
 
148
    >>> jeff.query.link('Journal').click()
 
149
 
 
150
    >>> print_navigators(jeff)
 
151
    Section: Baseball (1)
 
152
    Term: S2
 
153
    Year: 2012
 
154
 
 
155
If David logs in, he's redirected to his first section in 2011:
 
156
 
 
157
    >>> david = browsers.david
 
158
    >>> david.ui.login('david', 'pwd')
 
159
    >>> david.query.link('Journal').click()
 
160
 
 
161
    >>> print_navigators(david)
 
162
    Section: Math (1)
 
163
    Term: S1
 
164
    Year: 2011