This file is indexed.

/usr/share/pyshared/schooltool/course/stesting.py is in python-schooltool 1:2.1.0-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#
# SchoolTool - common information systems platform for school administration
# Copyright (c) 2012 Shuttleworth Foundation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
"""
Selenium Functional Testing Utilities for course.
"""
import os

from schooltool.testing.selenium import SeleniumLayer

dir = os.path.abspath(os.path.dirname(__file__))
filename = os.path.join(dir, 'stesting.zcml')

course_selenium_layer = SeleniumLayer(filename,
                                      __name__,
                                      'course_selenium_layer')

def registerSeleniumSetup():
    try:
        import selenium
    except ImportError:
        return
    from schooltool.testing import registry
    import schooltool.testing.selenium

    def addCourse(browser, schoolyear, title, **kw):
        optional = (
            'description',
            'course_id',
            'government_id',
            'credits',
            )
        browser.query.link('School').click()
        browser.query.link('Courses').click()
        browser.query.link(schoolyear).click()
        browser.query.link('Course').click()
        browser.query.name('form.widgets.title').type(title)
        for name in optional:
            if name in kw:
                value = kw[name]
                widget_id = ''.join(['form-widgets-', name])
                browser.query.id(widget_id).ui.set_value(value)
        page = browser.query.tag('html')
        browser.query.button('Submit').click()
        browser.wait(lambda: page.expired)

    registry.register('SeleniumHelpers',
        lambda: schooltool.testing.selenium.registerBrowserUI(
            'course.add', addCourse))

    def addSection(browser, schoolyear, term, course,
                   title=None, ends=None, **kw):
        optional = (
            'description',
            )
        browser.query.link('School').click()
        browser.query.link('Sections').click()
        browser.query.link(schoolyear).click()
        browser.query.link('Section').click()
        browser.query.id('courses-widgets-course').ui.select_option(course)
        browser.query.id('terms-widgets-starts').ui.select_option(term)
        ends_widget = browser.query.id('terms-widgets-ends')
        if ends is None:
            ends_widget.ui.select_option(term)
        else:
            ends_widget.ui.select_option(ends)
        for name in optional:
            if name in kw:
                value = kw[name]
                widget_id = ''.join(['form-widgets-', name])
                browser.query.id(widget_id).ui.set_value(value)
        page = browser.query.tag('html')
        browser.query.button('Submit').click()
        browser.wait(lambda: page.expired)
        if title is not None:
            page = browser.query.tag('html')
            browser.query.xpath('//a[@title="Edit this section"]').click()
            browser.wait(lambda: page.expired)
            title_widget = browser.query.id('form-widgets-title')
            title_widget.clear()
            title_widget.type(title)
            page = browser.query.tag('html')
            browser.query.button('Submit').click()
            browser.wait(lambda: page.expired)

    registry.register('SeleniumHelpers',
        lambda: schooltool.testing.selenium.registerBrowserUI(
            'section.add', addSection))

    def addInstructors(browser, schoolyear, term, section, instructors):
        browser.ui.section.go(schoolyear, term, section)
        selector = '//a[@title="Edit instructors for this section"]'
        browser.query.xpath(selector).click()
        selector = 'available_table-ajax-available_table--title'
        browser.query.id(selector).type(', '.join(instructors))
        selector = '#available_table-ajax-available_table- table'
        table = browser.query.css(selector)
        browser.query.name('SEARCH_BUTTON').click()
        browser.wait(lambda: table.expired)
        # XXX: Click Show All here in case there are lots of people
        selector = '#available_table-ajax-available_table- table'
        table = browser.query.css(selector)
        browser.query.name('ADD_DISPLAYED_RESULTS').click()
        browser.wait(lambda: table.expired)

    registry.register('SeleniumHelpers',
        lambda: schooltool.testing.selenium.registerBrowserUI(
            'section.instructors.add', addInstructors))

    def addStudents(browser, schoolyear, term, section, students):
        browser.ui.section.go(schoolyear, term, section)
        selector = '//a[@title="Edit students for this section"]'
        browser.query.xpath(selector).click()
        selector = 'available_table-ajax-available_table--title'
        browser.query.id(selector).type(', '.join(students))
        selector = '#available_table-ajax-available_table- table'
        table = browser.query.css(selector)
        browser.query.name('SEARCH_BUTTON').click()
        browser.wait(lambda: table.expired)
        # XXX: Click Show All here in case there are lots of people
        table = browser.query.tag('table')
        browser.query.name('ADD_DISPLAYED_RESULTS').click()
        browser.wait(lambda: table.expired)

    registry.register('SeleniumHelpers',
        lambda: schooltool.testing.selenium.registerBrowserUI(
            'section.students.add', addStudents))

    def visitSection(browser, schoolyear, term, section):
        browser.open('http://localhost/sections')
        browser.query.link(schoolyear).click()
        browser.query.id('SEARCH').type(section)
        table = browser.query.css('form table')
        browser.query.name('SEARCH_BUTTON').click()
        browser.wait(lambda: table.expired)
        # XXX: Click Show All here in case there are lots of sections
        selector = ('//td[following-sibling::*[contains(text(),"%s")]]'
                    '/a[text()="%s"]') % (term, section)
        page = browser.query.tag('html')
        browser.query.xpath(selector).click()
        browser.wait(lambda: page.expired)

    registry.register('SeleniumHelpers',
        lambda: schooltool.testing.selenium.registerBrowserUI(
            'section.go', visitSection))

registerSeleniumSetup()
del registerSeleniumSetup