当前位置: 首页>>代码示例>>Python>>正文


Python Root.Root类代码示例

本文整理汇总了Python中WMCore.WebTools.Root.Root的典型用法代码示例。如果您正苦于以下问题:Python Root类的具体用法?Python Root怎么用?Python Root使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Root类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: RESTBaseUnitTest

class RESTBaseUnitTest(unittest.TestCase):
    
    def setUp(self):
        # default set
        self.schemaModules = []
        self.initialize()
        if self.schemaModules:
            self.testInit = TestInitCouchApp(__file__)
            self.testInit.setLogging() # logLevel = logging.SQLDEBUG
            self.testInit.setDatabaseConnection(self.config.getDBUrl())
            self.testInit.setSchema(customModules = self.schemaModules,
                                    useDefault = False)
        
        self.rt = Root(self.config)
        self.rt.start(blocking=False)
        
    def tearDown(self):
        self.rt.stop()
        if self.schemaModules:
            self.testInit.clearDatabase()
        self.config = None
        
    
    def initialize(self):
        """
        i.e.
        
        self.config = DefaultConfig('WMCore.WebTools.RESTModel')
        self.config.setDBUrl("sqlite://")
        self.schemaModules = ["WMCore.ThreadPool", WMCore.WMBS"]
        """
        
        message = "initialize method has to be implemented, self.restModel, self.schemaModules needs to be set"
        raise NotImplementedError, message
开发者ID:zhiwenuil,项目名称:WMCore,代码行数:34,代码来源:RESTBaseUnitTest.py

示例2: testLongHandConfigurables

    def testLongHandConfigurables(self):
        """
        Test that the following configuration variables work:

        engine      Controls the "application engine", including autoreload.
                    These can only be declared in the global config.
        hooks       Declares additional request-processing functions.
        log         Configures the logging for each application. These can only
                    be declared in the global or / config.
        request         Adds attributes to each Request.
        response        Adds attributes to each Response.
        server      Controls the default HTTP server via cherrypy.server. These
                    can only be declared in the global config.
        tools       Runs and configures additional request-processing packages.
        wsgi        Adds WSGI middleware to an Application's "pipeline". These
                    can only be declared in the app's root config ("/").
        checker         Controls the "checker", which looks for common errors in app
                    state (including config) when the engine starts. Global config only.

        (from http://docs.cherrypy.org/dev/intro/concepts/config.html)
        """
        config = self.getBaseConfiguration()

        server = Root(config)
        server.start(blocking=False)
        server.stop()
开发者ID:BrunoCoimbra,项目名称:WMCore,代码行数:26,代码来源:Root_t.py

示例3: testInstanceInUrl

    def testInstanceInUrl(self):
        config = self.getBaseConfiguration()
        config.SecurityModule.dangerously_insecure = True
        server = Root(config)
        # Add our test page
        config.UnitTests.instances = ['foo', 'bar', 'baz/zoink']
        active = config.UnitTests.views.section_('active')
        active.section_('test')
        active.test.object = 'WMCore_t.WebTools_t.InstanceTestPage'
        active.test.section_('database')
        instances = active.test.database.section_('instances')
        foo = instances.section_('foo')
        bar = instances.section_('bar')
        baz = instances.section_('baz/zoink')
        foo.connectUrl = 'sqlite:///foo'
        bar.connectUrl = 'sqlite:///bar'
        baz.connectUrl = 'sqlite:///baz/zoink'
        server.start(blocking=False)

        #http://localhost:8080/unittests/bar/test/database
        for instance in config.UnitTests.instances:
            url = 'http://localhost:8080/unittests/%s/test' % instance
            html = urllib2.urlopen(url).read()
            self.assertEquals(html, instance)
            url = '%s/database' % url
            html = urllib2.urlopen(url).read()
            self.assertEquals(html, instances.section_(instance).connectUrl)
        server.stop()
开发者ID:zhiwenuil,项目名称:WMCore,代码行数:28,代码来源:Root_t.py

示例4: testShortHandChangePort

    def testShortHandChangePort(self):
        """
        Change the port the server runs on short hand
        """
        test_port = 8010

        config = self.getBaseConfiguration()
        # Set the port to a non-standard one
        config.Webtools.port = test_port

        server = Root(config)
        server.start(blocking=False)
        self.assertEqual(cpconfig['server.socket_port'], test_port)
        server.stop()
开发者ID:BrunoCoimbra,项目名称:WMCore,代码行数:14,代码来源:Root_t.py

示例5: testShortHandProxyBase

    def testShortHandProxyBase(self):
        """
        Check that changing the proxy_base via the short hand config variable
        does actually change the proxy base
        """
        test_proxy_base = '/unit_test'

        config = self.getBaseConfiguration()
        # Set the proxy base with a short hand cfg variable
        config.Webtools.proxy_base = test_proxy_base
        server = Root(config)

        server.start(blocking=False)
        self.assertEqual(cpconfig['tools.proxy.base'], test_proxy_base)
        server.stop()
开发者ID:BrunoCoimbra,项目名称:WMCore,代码行数:15,代码来源:Root_t.py

示例6: testLongHandProxyBase

    def testLongHandProxyBase(self):
        """
        Check that changing the proxy base via tools.proxy.base
        does actually change the proxy base
        """
        test_proxy_base = '/unit_test'

        config = self.getBaseConfiguration()
        config.Webtools.section_('tools')
        config.Webtools.tools.section_('proxy')
        config.Webtools.tools.proxy.base = test_proxy_base
        config.Webtools.tools.proxy.on = True
        server = Root(config)

        server.start(blocking=False)
        self.assertEqual(cpconfig['tools.proxy.base'], test_proxy_base)
        server.stop()
开发者ID:BrunoCoimbra,项目名称:WMCore,代码行数:17,代码来源:Root_t.py

示例7: testFakeLongHandConfigurables

    def testFakeLongHandConfigurables(self):
        """
        Test that a made up long hand configurable is ignored
        """
        config = self.getBaseConfiguration()
        # The following should be ignored by the configure step
        config.Webtools.section_('foo')
        config.Webtools.foo.bar = 'baz'
        config.Webtools.section_('stuff')
        config.Webtools.stuff = 'things'

        server = Root(config)
        server.start(blocking=False)

        self.assertFalse('foo' in cpconfig.keys(), 'non-standard configurable passed to server')
        self.assertFalse('stuff' in cpconfig.keys(), 'non-standard configurable passed to server')

        server.stop()
开发者ID:BrunoCoimbra,项目名称:WMCore,代码行数:18,代码来源:Root_t.py

示例8: testShortHandPortOverride

    def testShortHandPortOverride(self):
        """
        Change the port the server runs on long hand, then over ride
        it with the short hand equivalent
        """
        test_port = 8010

        config = self.getBaseConfiguration()
        # Set the port the long handed way
        config.Webtools.section_('server')
        config.Webtools.server.socket_port = test_port - 1
        # then override
        config.Webtools.port = test_port

        server = Root(config)
        server.start(blocking=False)
        self.assertEqual(cpconfig['server.socket_port'], test_port)
        server.stop()
开发者ID:BrunoCoimbra,项目名称:WMCore,代码行数:18,代码来源:Root_t.py

示例9: RESTBaseUnitTest

class RESTBaseUnitTest(unittest.TestCase):

    def setUp(self, initRoot = True):
        # default set
        self.schemaModules = []

        self.initialize()
        if self.schemaModules:
            import warnings
            warnings.warn("use RESTAndCouchUnitTest instead", DeprecationWarning)
            from WMQuality.TestInitCouchApp import TestInitCouchApp
            self.testInit = TestInitCouchApp(__file__)
            self.testInit.setLogging() # logLevel = logging.SQLDEBUG
            self.testInit.setDatabaseConnection()
            self.testInit.setSchema(customModules = self.schemaModules,
                                    useDefault = False)
            # Now pull the dbURL from the factory
            # I prefer this method because the factory has better error handling
            # Also because then you know everything is the same
            myThread = threading.currentThread()
            self.config.setDBUrl(myThread.dbFactory.dburl)

        logging.info("This is our config: %s" % self.config)

        self.initRoot = initRoot
        if initRoot:
            self.rt = Root(self.config, testName=self._testMethodName)
            try:
                self.rt.start(blocking=False)
            except RuntimeError, e:
                # there appears to be worker threads from a previous test
                # hanging out. Try to slay them so that we can keep going
                print "Failed to load cherrypy with exception: %s\n" % e
                print "The threads are: \n%s\n" % threading.enumerate()
                print "The previous test was %s\n" % self.rt.getLastTest()
                print traceback.format_exc()
                self.rt.stop()
                raise e

        return
开发者ID:cinquo,项目名称:WMCore,代码行数:40,代码来源:RESTBaseUnitTest.py

示例10: testInstanceInUrl

    def testInstanceInUrl(self):
        config = self.getBaseConfiguration()
        config.SecurityModule.dangerously_insecure = True
        server = Root(config)
        # Add our test page
        config.UnitTests.instances = ['foo', 'bar', 'baz/zoink']
        active = config.UnitTests.views.section_('active')
        active.section_('test')
        active.test.object = 'WMCore_t.WebTools_t.InstanceTestPage'
        active.test.section_('database')
        db_instances = active.test.database.section_('instances')
        foo = db_instances.section_('foo')
        bar = db_instances.section_('bar')
        baz = db_instances.section_('baz/zoink')
        foo.connectUrl = 'sqlite:///foo'
        bar.connectUrl = 'sqlite:///bar'
        baz.connectUrl = 'sqlite:///baz/zoink'
        active.test.section_('security')
        security_instances = active.test.security.section_('instances')
        sec_foo = security_instances.section_('foo')
        sec_bar = security_instances.section_('bar')
        sec_baz = security_instances.section_('baz/zoink')
        sec_foo.sec_params = 'test_foo'
        sec_bar.sec_params = 'test_bar'
        sec_baz.sec_params = 'test_baz'

        server.start(blocking=False)

        for instance in config.UnitTests.instances:
            url = 'http://127.0.0.1:%s/unittests/%s/test' % (cpconfig['server.socket_port'], instance)
            html = urllib2.urlopen(url).read()
            self.assertEqual(html, instance)
            db_url = '%s/database' % url
            html = urllib2.urlopen(db_url).read()
            self.assertEqual(html, db_instances.section_(instance).connectUrl)
            sec_url = '%s/security' % url
            html = urllib2.urlopen(sec_url).read()
            self.assertEqual(html, security_instances.section_(instance).sec_params)
        server.stop()
开发者ID:BrunoCoimbra,项目名称:WMCore,代码行数:39,代码来源:Root_t.py

示例11: testSecuritySetting

 def testSecuritySetting(self):
     testRole = "TestRole"
     testGroup = "TestGroup"
     testSite = "TestSite"
     config = self.getBaseConfiguration()
     config.SecurityModule.dangerously_insecure = False
     # not real keyfile but for the test.
     # file will be deleted automaticall when garbage collected.
     tempFile = NamedTemporaryFile()
     config.SecurityModule.key_file = tempFile.name
     config.SecurityModule.section_("default")
     config.SecurityModule.default.role = testRole
     config.SecurityModule.default.group = testGroup
     config.SecurityModule.default.site = testSite
     config.Webtools.environment = "production"
     server = Root(config)
     server.start(blocking=False)
     self.assertEqual(cpconfig['tools.secmodv2.on'], True)
     self.assertEqual(cpconfig['tools.secmodv2.role'], testRole)
     self.assertEqual(cpconfig['tools.secmodv2.group'], testGroup)
     self.assertEqual(cpconfig['tools.secmodv2.site'], testSite)
     server.stop()
开发者ID:BrunoCoimbra,项目名称:WMCore,代码行数:22,代码来源:Root_t.py

示例12: setUp

 def setUp(self):
     # default set
     self.schemaModules = []
     self.initialize()
     if self.schemaModules:
         self.testInit = TestInitCouchApp(__file__)
         self.testInit.setLogging() # logLevel = logging.SQLDEBUG
         self.testInit.setDatabaseConnection(self.config.getDBUrl())
         self.testInit.setSchema(customModules = self.schemaModules,
                                 useDefault = False)
     
     self.rt = Root(self.config)
     self.rt.start(blocking=False)
开发者ID:zhiwenuil,项目名称:WMCore,代码行数:13,代码来源:RESTBaseUnitTest.py

示例13: start

    def start(self):
        """
        _startComponent_

        Start up the cherrypy service for this component

        """
        root = Root(self.config)
        root.configureCherryPy()
        root.loadPages()
        root.makeIndex()
        cherrypy.engine.start()
        cherrypy.engine.block()
开发者ID:stuartw,项目名称:WMCore,代码行数:13,代码来源:HTTPFrontEnd.py

示例14: RESTBaseUnitTest

class RESTBaseUnitTest(unittest.TestCase):

    def setUp(self, initRoot = True):
        # default set
        self.schemaModules = []

        self.initialize()
        if self.schemaModules:
            import warnings
            warnings.warn("use RESTAndCouchUnitTest instead", DeprecationWarning)
            from WMQuality.TestInitCouchApp import TestInitCouchApp
            self.testInit = TestInitCouchApp(__file__)
            self.testInit.setLogging() # logLevel = logging.SQLDEBUG
            self.testInit.setDatabaseConnection( destroyAllDatabase = True )
            self.testInit.setSchema(customModules = self.schemaModules,
                                    useDefault = False)
            # Now pull the dbURL from the factory
            # I prefer this method because the factory has better error handling
            # Also because then you know everything is the same
            myThread = threading.currentThread()
            self.config.setDBUrl(myThread.dbFactory.dburl)

        logging.info("This is our config: %s" % self.config)

        self.initRoot = initRoot
        if initRoot:
            self.rt = Root(self.config, testName=self._testMethodName)
            try:
                self.rt.start(blocking=False)
            except RuntimeError as e:
                # there appears to be worker threads from a previous test
                # hanging out. Try to slay them so that we can keep going
                print "Failed to load cherrypy with exception: %s\n" % e
                print "The threads are: \n%s\n" % threading.enumerate()
                print "The previous test was %s\n" % self.rt.getLastTest()
                print traceback.format_exc()
                self.rt.stop()
                raise e

        return

    def tearDown(self):
        if self.initRoot:
            self.rt.stop()
            self.rt.setLastTest()
            # there was a ton of racy failures in REST tools because of
            # how much global state cherrypy has. this resets it

            # Also, it sucks I had to copy/paste this from
            # https://bitbucket.org/cherrypy/cherrypy/src/9720342ad159/cherrypy/__init__.py
            # but reload() doesn't have the right semantics

            cherrybus.bus = cherrybus.Bus()
            cherrypy.engine = cherrybus.bus
            cherrypy.engine.timeout_monitor = cherrypy._TimeoutMonitor(cherrypy.engine)
            cherrypy.engine.timeout_monitor.subscribe()

            cherrypy.engine.autoreload = cherrypy.process.plugins.Autoreloader(cherrypy.engine)
            cherrypy.engine.autoreload.subscribe()

            cherrypy.engine.thread_manager = cherrypy.process.plugins.ThreadManager(cherrypy.engine)
            cherrypy.engine.thread_manager.subscribe()

            cherrypy.engine.signal_handler = cherrypy.process.plugins.SignalHandler(cherrypy.engine)
            cherrypy.engine.subscribe('log', cherrypy._buslog)

            from cherrypy import _cpserver
            cherrypy.server = _cpserver.Server()
            cherrypy.server.subscribe()
            cherrypy.checker = cherrypy._cpchecker.Checker()
            cherrypy.engine.subscribe('start', cherrypy.checker)

        if self.schemaModules:
            self.testInit.clearDatabase()
        self.config = None
        return

    def initialize(self):
        """
        i.e.

        self.config = DefaultConfig('WMCore.WebTools.RESTModel')
        self.config.setDBUrl('sqlite://')
        self.schemaModules = ['WMCore.ThreadPool', 'WMCore.WMBS']
        """

        message = "initialize method has to be implemented, self.restModel, self.schemaModules needs to be set"
        raise NotImplementedError, message
开发者ID:pietverwilligen,项目名称:WMCore,代码行数:88,代码来源:RESTBaseUnitTest.py


注:本文中的WMCore.WebTools.Root.Root类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。