Exemple #1
0
    def test_noTracebacksDeprecation(self):
        """
        Passing --notracebacks is deprecated.
        """
        options = Options()
        options.parseOptions(["--notracebacks"])
        makeService(options)

        warnings = self.flushWarnings([self.test_noTracebacksDeprecation])
        self.assertEqual(warnings[0]['category'], DeprecationWarning)
        self.assertEqual(warnings[0]['message'],
                         "--notracebacks was deprecated in Twisted NEXT")
        self.assertEqual(len(warnings), 1)
Exemple #2
0
 def test_displayTracebacksNotGiven(self):
     """
     Not passing --display-tracebacks will leave traceback rendering on the
     generated Site off.
     """
     options = Options()
     options.parseOptions([])
     service = makeService(options)
     self.assertFalse(service.services[0].factory.displayTracebacks)
Exemple #3
0
 def test_displayTracebacks(self):
     """
     Passing --display-tracebacks will enable traceback rendering on the
     generated Site.
     """
     options = Options()
     options.parseOptions(["--display-tracebacks"])
     service = makeService(options)
     self.assertTrue(service.services[0].factory.displayTracebacks)
Exemple #4
0
 def test_add_header_resource(self):
     """
     When --add-header is specified, the resource is a composition that adds
     headers.
     """
     options = Options()
     options.parseOptions(
         ['--add-header', 'K1: V1', '--add-header', 'K2: V2'])
     service = makeService(options)
     resource = service.services[0].factory.resource
     self.assertIsInstance(resource, _AddHeadersResource)
     self.assertEqual(resource._headers, [('K1', 'V1'), ('K2', 'V2')])
     self.assertIsInstance(resource._originalResource, demo.Test)
Exemple #5
0
 def test_add_header_resource(self):
     """
     When --add-header is specified, the resource is a composition that adds
     headers.
     """
     options = Options()
     options.parseOptions(
         ["--add-header", "K1: V1", "--add-header", "K2: V2"])
     service = makeService(options)
     resource = service.services[0].factory.resource
     self.assertIsInstance(resource, _AddHeadersResource)
     self.assertEqual(resource._headers, [("K1", "V1"), ("K2", "V2")])
     self.assertIsInstance(resource._originalResource, demo.Test)
Exemple #6
0
 def test_personalServer(self):
     """
     The I{--personal} option to L{makeService} causes it to return a
     service which will listen on the server address given by the I{--port}
     option.
     """
     port = self.mktemp()
     options = Options()
     options.parseOptions(['--port', 'unix:' + port, '--personal'])
     service = makeService(options)
     service.startService()
     self.addCleanup(service.stopService)
     self.assertTrue(os.path.exists(port))
     self.assertTrue(stat.S_ISSOCK(os.stat(port).st_mode))
Exemple #7
0
 def test_personalServer(self):
     """
     The I{--personal} option to L{makeService} causes it to return a
     service which will listen on the server address given by the I{--port}
     option.
     """
     port = self.mktemp()
     options = Options()
     options.parseOptions(['--port', 'unix:' + port, '--personal'])
     service = makeService(options)
     service.startService()
     self.addCleanup(service.stopService)
     self.assertTrue(os.path.exists(port))
     self.assertTrue(stat.S_ISSOCK(os.stat(port).st_mode))
 def test_add_header_resource(self):
     """
     When --add-header is specified, the resource is a composition that adds
     headers.
     """
     options = Options()
     options.parseOptions(
         ['--add-header', 'K1: V1', '--add-header', 'K2: V2']
     )
     service = makeService(options)
     resource = service.services[0].factory.resource
     self.assertIsInstance(resource, _AddHeadersResource)
     self.assertEqual(resource._headers, [('K1', 'V1'), ('K2', 'V2')])
     self.assertIsInstance(resource._originalResource, demo.Test)
Exemple #9
0
 def test_pathServer(self):
     """
     The I{--path} option to L{makeService} causes it to return a service
     which will listen on the server address given by the I{--port} option.
     """
     path = FilePath(self.mktemp())
     path.makedirs()
     port = self.mktemp()
     options = Options()
     options.parseOptions(['--port', 'unix:' + port, '--path', path.path])
     service = makeService(options)
     service.startService()
     self.addCleanup(service.stopService)
     self.assertIsInstance(service.services[0].factory.resource, File)
     self.assertEqual(service.services[0].factory.resource.path, path.path)
     self.assertTrue(os.path.exists(port))
     self.assertTrue(stat.S_ISSOCK(os.stat(port).st_mode))
 def test_pathServer(self):
     """
     The I{--path} option to L{makeService} causes it to return a service
     which will listen on the server address given by the I{--port} option.
     """
     path = FilePath(self.mktemp())
     path.makedirs()
     port = self.mktemp()
     options = Options()
     options.parseOptions(['--port', 'unix:' + port, '--path', path.path])
     service = makeService(options)
     service.startService()
     self.addCleanup(service.stopService)
     self.assertIsInstance(service.services[0].factory.resource, File)
     self.assertEqual(service.services[0].factory.resource.path, path.path)
     self.assertTrue(os.path.exists(port))
     self.assertTrue(stat.S_ISSOCK(os.stat(port).st_mode))