This file is indexed.

/usr/lib/python2.7/dist-packages/twisted/lore/test/test_slides.py is in python-twisted-lore 13.2.0-1ubuntu1.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
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

"""
Tests for L{twisted.lore.slides}.
"""

from xml.dom.minidom import Element, Text

from twisted.trial.unittest import TestCase
from twisted.lore.slides import (
    HTMLSlide, splitIntoSlides, insertPrevNextLinks, MagicpointOutput)


class SlidesTests(TestCase):
    """
    Tests for functions in L{twisted.lore.slides}.
    """
    def test_splitIntoSlides(self):
        """
        L{splitIntoSlides} accepts a document and returns a list of two-tuples,
        each element of which contains the title of a slide taken from an I{h2}
        element and the body of that slide.
        """
        parent = Element('html')
        body = Element('body')
        parent.appendChild(body)

        first = Element('h2')
        text = Text()
        text.data = 'first slide'
        first.appendChild(text)
        body.appendChild(first)
        body.appendChild(Element('div'))
        body.appendChild(Element('span'))

        second = Element('h2')
        text = Text()
        text.data = 'second slide'
        second.appendChild(text)
        body.appendChild(second)
        body.appendChild(Element('p'))
        body.appendChild(Element('br'))

        slides = splitIntoSlides(parent)

        self.assertEqual(slides[0][0], 'first slide')
        firstContent = slides[0][1]
        self.assertEqual(firstContent[0].tagName, 'div')
        self.assertEqual(firstContent[1].tagName, 'span')
        self.assertEqual(len(firstContent), 2)

        self.assertEqual(slides[1][0], 'second slide')
        secondContent = slides[1][1]
        self.assertEqual(secondContent[0].tagName, 'p')
        self.assertEqual(secondContent[1].tagName, 'br')
        self.assertEqual(len(secondContent), 2)

        self.assertEqual(len(slides), 2)


    def test_insertPrevNextText(self):
        """
        L{insertPrevNextLinks} appends a text node with the title of the
        previous slide to each node with a I{previous} class and the title of
        the next slide to each node with a I{next} class.
        """
        next = Element('span')
        next.setAttribute('class', 'next')
        container = Element('div')
        container.appendChild(next)
        slideWithNext = HTMLSlide(container, 'first', 0)

        previous = Element('span')
        previous.setAttribute('class', 'previous')
        container = Element('div')
        container.appendChild(previous)
        slideWithPrevious = HTMLSlide(container, 'second', 1)

        insertPrevNextLinks(
            [slideWithNext, slideWithPrevious], None, None)

        self.assertEqual(
            next.toxml(), '<span class="next">second</span>')
        self.assertEqual(
            previous.toxml(), '<span class="previous">first</span>')



class MagicpointOutputTests(TestCase):
    """
    Tests for L{lore.slides.MagicpointOutput}.
    """
    def setUp(self):
        self.filename = self.mktemp()
        self.output = []
        self.spitter = MagicpointOutput(self.output.append,
            filename=self.filename)

        self.parent = Element('html')
        title = Element('title')
        text = Text()
        text.data = "My Title"
        title.appendChild(text)
        self.body = Element('body')
        self.parent.appendChild(title)
        self.parent.appendChild(self.body)


    def test_body(self):
        """
        L{MagicpointOutput.visitNode} emits a verbatim block when it encounters
        a I{body} element.
        """
        link = Element('link')
        link.setAttribute('class', 'author')
        text = Text()
        text.data = u"John Doe"
        link.appendChild(text)
        self.body.appendChild(link)

        head = Element('h2')
        first = Text()
        first.data = u'My Header'
        head.appendChild(first)
        self.body.appendChild(head)

        self.spitter.visitNode(self.parent)
        self.assertEqual(
            ''.join(self.output),
            '%page\n\nMy Title\n\n\n%center\n\n\n\n\nJohn Doe\n%page\n\n'
            'My Title\n\n\n\tMy Header\nJohn Doe%page\n\nMy Header\n\n\n')


    def test_pre(self):
        """
        L{MagicpointOutput.visitNode} emits the 'typewriter' font when it
        encounters a I{pre} element.
        """
        pre = Element('pre')
        text = Text()
        text.data = u"\nfirst line\nsecond line\n\n"
        pre.appendChild(text)
        self.body.appendChild(pre)

        self.spitter.visitNode(self.parent)
        self.assertEqual(
            ''.join(self.output),
            '%page\n\nMy Title\n\n\n%center\n\n\n\n\n%page\n\nMy Title\n\n\n'
            '%font "typewriter", size 4\n first line\n second line\n \n'
            '%font "standard"\n')