This file is indexed.

/usr/lib/python2.7/dist-packages/sagenb/testing/tests/test_worksheet.py is in python-sagenb 1.0.1+ds1-2.

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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# -*- coding: utf-8 -*-
"""
Tests for SageNB Worksheets

AUTHORS:

- Mike Hansen (?) -- initial revision

- Tim Dumol (Oct. 28, 2009) -- made the tests work again. Separated
  this out. Added some more tests.
"""

import unittest, re

from sagenb.testing.notebook_test_case import NotebookTestCase

class TestWorksheet(NotebookTestCase):
    def setUp(self):
        super(TestWorksheet, self).setUp()
        self.login_as('admin', 'asdfasdf')
        self.create_new_worksheet()

    def test_7433(self):
        """
        Tests that #7433 notebook: changing title of worksheet changes
        title of corresponding published worksheet has been fixed.
        """
        sel = self.selenium
        self.rename_worksheet(u'To be publishedЋĉƸḾ﹢Յй')
        self.publish_worksheet()
        self.save_and_quit()

        sel.click('link=Published')
        sel.wait_for_page_to_load(30000)
        self.open_worksheet_with_name(u'To be publishedЋĉƸḾ﹢Յй')
        self.assert_(sel.is_element_present(u'//h1[contains(@class, "title") and contains(text(), "To be publishedЋĉƸḾ﹢Յй")]'))

        sel.open('/home/admin')
        sel.wait_for_page_to_load(30000)
        self.open_worksheet_with_name(u'To be publishedЋĉƸḾ﹢Յй')
        self.rename_worksheet('This has been published')
        self.save_and_quit()

        sel.click('link=Published')
        sel.wait_for_page_to_load(30000)
        self.open_worksheet_with_name('To be published')
        self.assert_(sel.is_element_present('//h1[contains(@class, "title") and contains(text(), "To be published")]'))

        sel.open('/home/admin')
    
    def test_7434(self):
        """
        Tests that #7434 (notebook: new modal jquery dialog boxes are covered
        by jmol 3d graphics) has been fixed.
        """
        sel = self.selenium
        self.eval_cell(1, "sphere()")
        java_applet_selector = 'object[type="application/x-java-applet"]'
        self.wait_in_window("return this.$('%s').length > 0"
            % java_applet_selector, 30000)
        sel.click("worksheet_title")
        self.wait_in_window("""
            var obj = this.$('%s');
            var offset = obj.offset();
            return offset.left + obj.width() < 0;""" % java_applet_selector,
            30000)
        sel.click("css=.ui-widget-overlay")
        self.wait_in_window("""
            var obj = this.$('%s');
            var offset = obj.offset();
            return offset.left > 0;""" % java_applet_selector,
            30000)
        

    def test_edit(self):
        sel = self.selenium
        sel.click('link=Edit')
        sel.wait_for_page_to_load("30000")

        sel.type('//textarea[@id="cell_intext"]',
                 u'''
{{{id=1|
print(5 + 5)
print(u'ЋĉƸḾ﹢Յй')
///
15
ЋĉƸḾ﹢Յй
}}}

{{{id=2|
print(13)
///
}}}
''')
        sel.click('id=button_save')
        sel.wait_for_page_to_load(30000)

        self.assert_(sel.is_element_present(u'//textarea[@id="cell_input_1" and '
                                            u'contains(text(),"print(5 + 5)") and '
                                            u'contains(text(), "ЋĉƸḾ﹢Յй")]'))
        self.assert_(sel.is_element_present('//textarea[@id="cell_input_2" and contains(text(),"print(13)")]'))

        self.assertEqual(self.get_cell_output(1), u'15\nЋĉƸḾ﹢Յй')

    def test_7341(self):
        sel = self.selenium
        sel.type('cell_input_1', 'fo')
        self.introspect(1)

        sel.wait_for_condition('selenium.browserbot.getCurrentWindow().$("div.introspection ul").length > 0', 10000)

        self.assert_(sel.is_element_present('//a[text()="forall"]'))
        self.assert_(sel.is_element_present('//a[text()="forget"]'))
        self.assert_(sel.is_element_present('//a[text()="format"]'))
        self.assert_(sel.is_element_present('//a[text()="four_squares"]'))
        self.assert_(sel.is_element_present('//a[text()="fortran"]'))

    def test_3957(self):
        """
        Check to make sure that Trac #3957 works.
        """
        sel = self.selenium
        out = self.eval_cell(1, "plot(x^2, x)")

        self.assertTrue(u'<img src="/home/admin/0/cells/1/sage0.png?'
                        in out.lower())

        self.save_and_quit()

        sel.click("id=name-admin-0")
        sel.wait_for_page_to_load("30000")

        self.assertTrue(u'<img src="/home/admin/0/cells/1/sage0.png?'
                        in self.get_cell_output(1))

    def test_3711(self):
        """
        Check to make sure that Trac #3711 works.
        """
        sel = self.selenium
        self.rename_worksheet("Test Worksheet")
        self.save_and_quit()

        # Delete the worksheet.
        sel.click("//input[@id='admin-0' and @type='checkbox']")
        sel.click("//button[@onclick='delete_button();']")
        sel.wait_for_page_to_load("30000")
        sel.click("link=Trash")
        sel.wait_for_page_to_load("30000")

        self.assert_(sel.is_text_present('Test Worksheet'),
                     'worksheet was not moved to trash')
        self.logout()

        # Stop the notebook and start it back up again.
        self.stop_notebook()
        self.start_notebook()

        # Log in as the admin user.
        sel.open('/')
        self.login_as('admin', 'asdfasdf')

        # Check to make sure the test worksheet is still in the trash.
        sel.click("link=Trash")
        sel.wait_for_page_to_load("30000")
        self.assert_(sel.is_text_present('Test Worksheet'),
                     'worksheet was not in trash')

        # Empty the trash.
        sel.click("link=(Empty Trash)")
        self.failUnless(re.search(r"^Emptying the trash will permanently delete all items in the trash\. Continue[\s\S]$", sel.get_confirmation()))
        sel.wait_for_page_to_load("30000")
        self.wait_for_title('Deleted Worksheets -- Sage')

        # Leave and make sure that the file was actually deleted.
        sel.click("link=Active")
        sel.wait_for_page_to_load("30000")
        sel.click("link=Trash")
        sel.wait_for_page_to_load("30000")
        self.assert_(not sel.is_text_present('Test Worksheet'),
                     'trash was not emptied')

        # Create a new worksheet.
        self.create_new_worksheet()
        self.rename_worksheet("Archive Worksheet")
        self.save_and_quit()

        # Archive it.
        sel.click("//input[@id='admin-1']")
        sel.click("//button[@onclick='archive_button();']")
        sel.wait_for_page_to_load("30000")
        sel.click("link=Archived")
        sel.wait_for_page_to_load("30000")

        self.assert_(sel.is_text_present('Archive Worksheet'),
                     'worksheet was not archived')

        # Stop the notebook and start it back up again.
        self.stop_notebook()
        self.start_notebook()

        # Log in as the admin user.
        sel.open('/')
        self.login_as('admin', 'asdfasdf')

        self.assert_(not sel.is_text_present('Archive Worksheet'),
                     'worksheet was in the active list')

        # Check to make sure the test worksheet is still in the archive.
        sel.click("link=Archived")
        sel.wait_for_page_to_load("30000")
        self.assert_(sel.is_text_present('Archive Worksheet'),
                     'worksheet was not in the archive')
    
    def test_8208(self):
        """
        Check the fix for trac #8208: Click "No" actually publishes a worksheet.
        """
        sel = self.selenium
        self.create_new_worksheet('published_worksheet')
        self.publish_worksheet()
        self.assertTrue(self.is_worksheet_published('published_worksheet'))
        self.create_new_worksheet('not_p_ws')
        sel.click("link=Publish")
        sel.wait_for_page_to_load("30000")
        sel.click("//input[@value='No']")
        sel.wait_for_page_to_load("30000")
        self.assertFalse(self.is_worksheet_published('not_p_ws'))        

    def test_simple_evaluation(self):
        """
        Check to see that we can perform some simple computations and get the
        correct answers.
        """
        out = self.eval_cell(1, "2+2")
        self.assertEqual(out, '4')

    def test_operations1(self):
        sel = self.selenium
        out = self.eval_cell(1, "%hide\n%html\n<h1>For testing purposes</h1>")

        # Browser contortions.  TODO: Use regular expressions?
        try:
            self.assertEqual(out.lower(), """<font color="black"><h1>for testing purposes</h1></font>""")
        except AssertionError:
            self.assertEqual(out.lower(), """<font color=black><h1>for testing purposes</h1></font>""")

        out = self.eval_cell(2, "var('a b c d')")
        self.assertEqual(out, '(a, b, c, d)')

        out = self.eval_cell(3, "expr1 = a+b - c + 2*d\nexpr2 = d*c-a*b")
        self.assertEqual(out, '')

        out = self.eval_cell(4, "expr1")
        self.assertEqual(out, u'a + b - c + 2*d')

        out = self.eval_cell(5, "expr2")
        self.assertEqual(out, u'-a*b + c*d')

        sel.select("id=action-menu", "label=Action...")
        sel.click("//option[@value='evaluate_all();']")

    def tearDown(self):
        self.logout()
        super(TestWorksheet, self).tearDown()


suite = unittest.TestLoader().loadTestsFromTestCase(TestWorksheet)

if __name__ == '__main__':
    unittest.main()