Esempio n. 1
0
 def test_after_attribute_exception(self):
     self.app = Application.factory(root=BadController, **test_config)
     response, data = self.assertRPCResponse(
         "test", status="500 Internal Server Error", content_type="application/json"
     )
     self.assertEquals(
         data,
         dict(
             id=1,
             result=None,
             error=dict(
                 message="'BadController' object has no attribute 'nonexisting'",
                 code=100,
                 name="JSONRPCError",
                 error="Not disclosed.",
             ),
         ),
     )
Esempio n. 2
0
 def test_enforceroot(self):
     self.assertRaises(ValueError, lambda: Application.factory(root=dict()))
Esempio n. 3
0
 def test_autostatic(self):
     Application.factory(root=RootController, **{'web.static': True})
Esempio n. 4
0
 def test_dotload(self):
     self.assertRaises(TypeError, lambda: Application.factory(root='web.core.application:Application', **test_config))
Esempio n. 5
0


class TestService(AMFController):
    def hello(self, name="world"):
        return "Hello, %(name)s!" % dict(name=name)


class RootController(AMFController):
    test = TestService()



if __name__ == '__main__':
    import logging
    from paste import httpserver
    from web.core import Application
    
    logging.basicConfig(level=logging.INFO)
    
    app = Application.factory(root=RootController, debug=False, **{
            'web.sessions': False,
            'web.widgets': False,
            'web.beaker': False,
            'web.profile': False,
            'web.static': False,
            'web.compress': False
        })
    
    httpserver.serve(app, host='127.0.0.1', port='8080')
Esempio n. 6
0
        return ", ".join([i.name for i in session.query(Foo).order_by('name').all()])
        

test_config = {
        'debug': False,
        'web.widgets': False,
        'web.sessions': False,
        'web.compress': False,
        'web.static': False,
        'db.connections': 'test',
        'db.test.engine': 'sqlalchemy',
        'db.test.model': RootController.__module__,
        'db.test.url': 'sqlite:///:memory:'
    }

app = Application.factory(root=RootController, **test_config)


class TestSASession(WebTestCase):
    app = app
    
    def test_index(self):
        self.assertResponse('/', body='success')
    
    def test_in_session(self):
        response = self.assertResponse('/in_session')
        assert response.body.startswith('<sqlalchemy.orm.session.Session object')
    
    def test_http_exceptions(self):
        self.assertResponse('/http_ok', '200 OK', 'text/plain')
        self.assertResponse('/http_error', '500 Internal Server Error', 'text/plain')
Esempio n. 7
0
File: rest.py Progetto: dsx/WebCore
    def post(self, name="world"):
        return "Hello %s!" % (name,)


class RootController(Controller):
    index = Index()


if __name__ == "__main__":
    import logging
    from paste import httpserver
    from web.core import Application

    logging.basicConfig(level=logging.INFO)

    app = Application.factory(
        root=RootController,
        debug=False,
        **{
            "web.sessions": False,
            "web.widgets": False,
            "web.sessions": False,
            "web.profile": False,
            "web.static": False,
            "web.compress": False,
        }
    )

    httpserver.serve(app, host="127.0.0.1", port="8080")
Esempio n. 8
0
#!/usr/bin/env python
# encoding: utf-8

"""A basic hello world application.

This can be simplified down to 5 lines in total; two import lines, two
controller lines, and one line to serve it.
"""

from web.core import Controller



class RootController(Controller):
    def index(self):
        return 'Hello world!'



if __name__ == '__main__':
    import logging
    from paste import httpserver
    from web.core import Application
    
    logging.basicConfig(level=logging.INFO)
    
    app = Application.factory(root=RootController, debug=True, **{'web.static': True, 'web.static.root': '/static'})
    
    httpserver.serve(app, host='127.0.0.1', port='8080')
Esempio n. 9
0
#!/usr/bin/env python
# encoding: utf-8

"""A basic hello world application.

This can be simplified down to 5 lines in total; two import lines, two
controller lines, and one line to serve it.
"""

from web.core import Controller


class RootController(Controller):
    def index(self):
        return 'Hello world!'

    def hello(self, name):
        return "Hello, %(name)s!" % dict(name=name)


if __name__ == '__main__':
    import logging
    from paste import httpserver
    from web.core import Application

    logging.basicConfig(level=logging.INFO)

    app = Application.factory(root=RootController, debug=False)

    httpserver.serve(app, host='127.0.0.1', port='8080')
Esempio n. 10
0
#!/usr/bin/env python
# encoding: utf-8

"""A basic hello world application.

This can be simplified down to 5 lines in total; two import lines, two
controller lines, and one line to serve it.
"""
import logging

from paste import httpserver

from web.core import Application
from web.rpc.amf import AMFController


class TestService(AMFController):
    def hello(self, name="world"):
        return "Hello, %(name)s!" % dict(name=name)


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    app = Application.factory(root=TestService, debug=False)
    httpserver.serve(app, host='127.0.0.1', port='8080')
Esempio n. 11
0
#!/usr/bin/env python
# encoding: utf-8

"""A basic hello world application.

This can be simplified down to 5 lines in total; two import lines, two
controller lines, and one line to serve it.
"""
import logging

from paste import httpserver

from web.core import Application
from web.rpc.xml import XMLRPCController


class TestService(XMLRPCController):
    def hello(self, name="world"):
        return "Hello, %(name)s!" % dict(name=name)


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    app = Application.factory(root=TestService)
    httpserver.serve(app, host='127.0.0.1', port='8080')
Esempio n. 12
0
"""A basic hello world application.

This can be simplified down to 5 lines in total; two import lines, two
controller lines, and one line to serve it.
"""
import logging

from paste import httpserver

from web.core import Application
from web.rpc.xml import XMLRPCController


class TestService(XMLRPCController):
    def hello(self, name="world"):
        return "Hello, %(name)s!" % dict(name=name)


class RootController(XMLRPCController):
    test = TestService()


if __name__ == '__main__':
    logging.basicConfig(level=logging.INFO)
    app = Application.factory(root=RootController)
    httpserver.serve(app, host='127.0.0.1', port='8080')