This file is indexed.

/usr/share/pyshared/mygpoclient/json_test.py is in python-mygpoclient 1.7-1.

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
# -*- coding: utf-8 -*-
# gpodder.net API Client
# Copyright (C) 2009-2013 Thomas Perl and the gPodder Team
#
# 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 StringIO import StringIO
import urllib2

from mygpoclient import http
from mygpoclient import json

import unittest
import minimock

class Test_JsonClient(unittest.TestCase):
    USERNAME = 'john'
    PASSWORD = 'secret'

    def setUp(self):
        self.mockopener = minimock.Mock('urllib2.OpenerDirector')
        urllib2.build_opener = minimock.Mock('urllib2.build_opener')
        urllib2.build_opener.mock_returns = self.mockopener

    def tearDown(self):
        minimock.restore()

    def mock_setHttpResponse(self, value):
        self.mockopener.open.mock_returns = StringIO(value)

    def test_parseResponse_worksWithDictionary(self):
        client = json.JsonClient(self.USERNAME, self.PASSWORD)
        self.mock_setHttpResponse('{"a": "B", "c": "D"}')
        items = list(sorted(client.GET('/').items()))
        self.assertEquals(items, [('a', 'B'), ('c', 'D')])

    def test_parseResponse_worksWithIntegerList(self):
        client = json.JsonClient(self.USERNAME, self.PASSWORD)
        self.mock_setHttpResponse('[1,2,3,6,7]')
        self.assertEquals(client.GET('/'), [1,2,3,6,7])

    def test_parseResponse_emptyString_returnsNone(self):
        client = json.JsonClient(self.USERNAME, self.PASSWORD)
        self.mock_setHttpResponse('')
        self.assertEquals(client.GET('/'), None)

    def test_invalidContent_raisesJsonException(self):
        client = json.JsonClient(self.USERNAME, self.PASSWORD)
        self.mock_setHttpResponse('this is not a valid json string')
        self.assertRaises(json.JsonException, client.GET, '/')