def test_lazy_services(self):
        service_mappings = protorpc.service_mapping([
            ('/bonjour', 'resources.protorpc_services.BonjourService'),
            'resources.protorpc_services.CiaoService',
        ])
        app = webapp2.WSGIApplication(service_mappings, debug=True)

        # Bonjour
        req = webapp2.Request.blank('/bonjour.bonjour')
        req.method = 'POST'
        req.headers['Content-Type'] = 'application/json'
        req.body = '{"my_name": "bob"}'

        rsp = req.get_response(app)
        self.assertEqual(rsp.status_int, 200)
        self.assertEqual(rsp.body, '{"hello": "Bonjour, bob!"}')

        # Ciao
        req = webapp2.Request.blank('/resources/protorpc_services/CiaoService.ciao')
        req.method = 'POST'
        req.headers['Content-Type'] = 'application/json'
        req.body = '{"my_name": "bob"}'

        rsp = req.get_response(app)
        self.assertEqual(rsp.status_int, 200)
        self.assertEqual(rsp.body, '{"hello": "Ciao, bob!"}')
Пример #2
0
    def test_lazy_services(self):
        service_mappings = protorpc.service_mapping([
            ('/bonjour', 'resources.protorpc_services.BonjourService'),
            'resources.protorpc_services.CiaoService',
        ])
        app = webapp2.WSGIApplication(service_mappings)

        # Bonjour
        req = webapp2.Request.blank('/bonjour.bonjour')
        req.method = 'POST'
        req.headers['Content-Type'] = 'application/json'
        req.body = '{"my_name": "bob"}'

        rsp = req.get_response(app)
        self.assertEqual(rsp.status_int, 200)
        self.assertEqual(rsp.body, '{"hello": "Bonjour, bob!"}')

        # Ciao
        req = webapp2.Request.blank('/resources/protorpc_services/CiaoService.ciao')
        req.method = 'POST'
        req.headers['Content-Type'] = 'application/json'
        req.body = '{"my_name": "bob"}'

        rsp = req.get_response(app)
        self.assertEqual(rsp.status_int, 200)
        self.assertEqual(rsp.body, '{"hello": "Ciao, bob!"}')
Пример #3
0
def main():
	
		service_mappings = generateServiceMappings(services_config)
		if service_mappings is not None:
			## Map URL's to services
			service_mappings = protorpc.service_mapping(service_mappings)
	
			application = webapp.WSGIApplication(service_mappings)
	
			util.run_wsgi_app(application)
Пример #4
0
def main():

    service_mappings = generateServiceMappings(services_config)
    if service_mappings is not None:
        ## Map URL's to services
        service_mappings = protorpc.service_mapping(service_mappings)

        application = webapp.WSGIApplication(service_mappings)

        util.run_wsgi_app(application)
        raise ValueError()

class AhoyService(remote.Service):
    @remote.method(HelloRequest, HelloResponse)
    def ahoy(self, request):
        return HelloResponse(hello='Ahoy, %s!' %
                             request.my_name)

class HolaService(remote.Service):
    @remote.method(HelloRequest, HelloResponse)
    def hola(self, request):
        return HelloResponse(hello='Hola, %s!' %
                             request.my_name)

service_mappings = protorpc.service_mapping([
    ('/hello', HelloService),
    AhoyService,
])
app = webapp2.WSGIApplication(service_mappings, debug=True)

service_mappings2 = protorpc.service_mapping({
    '/hola': HolaService,
})
app2 = webapp2.WSGIApplication(service_mappings2, debug=True)

# Tests -----------------------------------------------------------------------

class TestProtoRPC(test_base.BaseTestCase):

    def test_example(self):
        req = webapp2.Request.blank('/hello.hello')
        req.method = 'POST'
Пример #6
0
        raise ValueError()

class AhoyService(remote.Service):
    @remote.method(HelloRequest, HelloResponse)
    def ahoy(self, request):
        return HelloResponse(hello='Ahoy, %s!' %
                             request.my_name)

class HolaService(remote.Service):
    @remote.method(HelloRequest, HelloResponse)
    def hola(self, request):
        return HelloResponse(hello='Hola, %s!' %
                             request.my_name)

service_mappings = protorpc.service_mapping([
    ('/hello', HelloService),
    AhoyService,
])
app = webapp2.WSGIApplication(service_mappings)

service_mappings2 = protorpc.service_mapping({
    '/hola': HolaService,
})
app2 = webapp2.WSGIApplication(service_mappings2)

# Tests -----------------------------------------------------------------------

class TestProtoRPC(test_base.BaseTestCase):

    def test_example(self):
        req = webapp2.Request.blank('/hello.hello')
        req.method = 'POST'