This file is indexed.

/usr/lib/python3/dist-packages/autopilot/tests/unit/test_vis_bus_enumerator.py is in python3-autopilot-tests 1.4+14.04.20140416-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
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
#
# Autopilot Functional Test Tool
# Copyright (C) 2013 Canonical
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
#


from mock import patch, Mock
from testtools import TestCase
from textwrap import dedent

from autopilot.vis.dbus_search import XmlProcessor


class BusEnumeratorXmlProcessorTest(TestCase):

    _example_connection_name = "com.autopilot.test"

    def test_invalid_xml_doesnt_raise_exception(self):
        xml = "<invalid xml>"
        xml_processor = XmlProcessor()

        xml_processor(self._example_connection_name, "/", xml)

    @patch('autopilot.vis.dbus_search._logger')
    def test_invalid_xml_logs_details(self, logger_meth):
        xml = "<invalid xml>"
        xml_processor = XmlProcessor()

        xml_processor(self._example_connection_name, "/", xml)

        logger_meth.warning.assert_called_once_with(
            'Unable to parse XML response for com.autopilot.test (/)'
        )

    def test_on_success_event_called(self):
        xml = dedent(
            '<node>'
            '<interface name="org.autopilot.DBus.example"></interface>'
            '</node>'
        )

        success_callback = Mock()
        xml_processor = XmlProcessor()
        xml_processor.set_success_callback(success_callback)

        xml_processor(self._example_connection_name, "/", xml)

        success_callback.assert_called_with(
            self._example_connection_name,
            "/",
            "org.autopilot.DBus.example",
        )

    def test_nodes_are_recursively_searched(self):
        xml = dedent(
            '<node>'
            '<node name="example">'
            '<interface name="org.autopilot.DBus.example"></interface>'
            '</node>'
            '</node>'
        )
        dbus_inspector = Mock()
        xml_processor = XmlProcessor()
        xml_processor.set_dbus_inspector(dbus_inspector)

        xml_processor(self._example_connection_name, "/", xml)

        dbus_inspector.assert_called_with(
            self._example_connection_name,
            "/example"
        )