Ejemplo n.º 1
0
def start_server(generation):
    """Starts the cherrypy server and blocks.
   
    @param generation: string unique to this instance of the fake device server.

    """
    fail_control_handler = fail_control.FailControl()
    cherrypy.tree.mount(
        fail_control_handler, '/' + fail_control.FAIL_CONTROL_PATH,
        {'/': {
            'request.dispatch': cherrypy.dispatch.MethodDispatcher()
        }})
    oauth_handler = oauth.OAuth(fail_control_handler)
    commands_handler = commands.Commands(oauth_handler, fail_control_handler)
    cherrypy.tree.mount(
        commands_handler, '/' + commands.COMMANDS_PATH,
        {'/': {
            'request.dispatch': cherrypy.dispatch.MethodDispatcher()
        }})
    devices_resource = resource_delegate.ResourceDelegate({})
    # TODO(wiley): We need to validate device commands.
    devices_handler = devices.Devices(devices_resource, commands_handler,
                                      oauth_handler, fail_control_handler)
    cherrypy.tree.mount(
        devices_handler, '/' + devices.DEVICES_PATH,
        {'/': {
            'request.dispatch': cherrypy.dispatch.MethodDispatcher()
        }})
    tickets = resource_delegate.ResourceDelegate({})
    registration_tickets_handler = registration_tickets.RegistrationTickets(
        tickets, devices_handler, fail_control_handler)
    cherrypy.tree.mount(
        registration_tickets_handler,
        '/' + registration_tickets.REGISTRATION_PATH,
        {'/': {
            'request.dispatch': cherrypy.dispatch.MethodDispatcher()
        }})
    cherrypy.tree.mount(
        oauth_handler, '/' + oauth.OAUTH_PATH,
        {'/': {
            'request.dispatch': cherrypy.dispatch.MethodDispatcher()
        }})
    cherrypy.tree.mount(
        meta_handler.MetaHandler(generation),
        '/' + meta_handler.META_HANDLER_PATH,
        {'/': {
            'request.dispatch': cherrypy.dispatch.MethodDispatcher()
        }})
    # Don't parse POST for params.
    cherrypy.config.update({'global': {'request.process_request_body': False}})
    cherrypy.engine.start()
Ejemplo n.º 2
0
    def setUp(self):
        """Sets up mox and a ticket / registration objects."""
        mox.MoxTestBase.setUp(self)
        self.tickets = {}
        self.devices_resource = {}
        self.fail_control = fail_control.FailControl()
        self.oauth = oauth.OAuth(self.fail_control)
        self.commands = commands.Commands(self.oauth, self.fail_control)
        self.devices = devices.Devices(
            resource_delegate.ResourceDelegate(self.devices_resource),
            self.commands, self.oauth, self.fail_control)

        self.registration = registration_tickets.RegistrationTickets(
            resource_delegate.ResourceDelegate(self.tickets), self.devices,
            self.fail_control)
Ejemplo n.º 3
0
 def setUp(self):
     """Sets up resource_method object and dict of resources."""
     mox.MoxTestBase.setUp(self)
     self.resources = {}
     self.resource_method = resource_method.ResourceMethod(
             resource_delegate.ResourceDelegate(self.resources))