/usr/lib/python2.7/dist-packages/pygopherd/initializationTest.py is in pygopherd 2.0.18.3+nmu4ubuntu1.
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 | #!/usr/bin/python
# Python-based gopher server
# Module: test of initialization code
# COPYRIGHT #
# Copyright (C) 2002 John Goerzen
#
# 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; version 2 of the License.
#
# 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
# END OF COPYRIGHT #
import unittest, SocketServer, mimetypes
from pygopherd import initialization
from pygopherd import logger, fileext
class initializationConfigTestCase(unittest.TestCase):
def testinitconffile(self):
self.assertRaises(Exception, initialization.initconffile,
'/foo')
# Load the standard config file. It should be OK at least.
config = initialization.initconffile('conf/pygopherd.conf')
assert not config.has_option("pygopherd", "servername"), \
"servername should be disabled by default"
self.assertEqual(config.getint("pygopherd", "port"), 70,
"Port should be 70")
self.assertEqual(config.get("pygopherd", "servertype"),
"ForkingTCPServer",
"Servertype should be ForkingTCPServer")
assert config.getboolean("pygopherd", "tracebacks"), \
"Tracebacks should be enabled."
class initializationGeneralTestCase(unittest.TestCase):
def setUp(self):
self.config = initialization.initconffile('conf/pygopherd.conf')
def testinitlogger(self):
# FIXME Can't really test this.
pass
def testinitmimetypes_except(self):
self.config.set("pygopherd", "mimetypes", "/foo:/bar")
self.assertRaises(Exception, initialization.initmimetypes,
self.config)
def testinitmimetypes(self):
# Logger is required for this test.
self.config.set("logger", "logmethod", "none")
initialization.initlogger(self.config, 'TESTING')
initialization.initmimetypes(self.config)
self.assertEqual(mimetypes.types_map['.txt'], 'text/plain')
self.assertEqual(mimetypes.encodings_map['.bz2'], 'bzip2')
assert '.txt' in fileext.typemap['text/plain']
def testgetserverobject(self):
self.config.set("pygopherd", "port", "22270")
s = initialization.getserverobject(self.config)
assert isinstance(s, SocketServer.ForkingTCPServer)
def testinitsecurity(self):
#FIXME
pass
|