Example #1
0
def make_app(global_conf, **app_conf):
    global config
    global_conf.update(app_conf)
    conf = global_conf
    pm = conf.pop("postmortem", "false")
    max_size = conf.get("upload_max_size", 150000)
    udd = conf.get("upload_dest_dir", None)

    conf["ogreport.engine"] = engine_from_config(conf)
    app = wee.make_app()
    app = FeatureServerMiddleware(app, conf["sqlalchemy.url"])
    app = ConfigMiddleware(app, conf, dispatching_config=config, environ_key="ogreport.config")
    app = tm.TM(app)

    if udd is not None:
        # hexd = hashlib.sha1(str(datetime.datetime.now())).hexdigest()
        tmpdir = os.path.join(tempfile.gettempdir(), "ogreporter")
        app = Storage(app, upload_to=udd, tempdir=tmpdir, max_size=max_size)

    if pm != "false":
        from repoze.debug.pdbpm import PostMortemDebug

        app = PostMortemDebug(app)

    app.conf = conf.copy()
    return app
Example #2
0
def app_factory(udd=None, max_size=150000, repo_dir=data, cache_age=None, pm=True, config=None):
    app = wee.make_app()
    
    tmpdir =  os.path.join(tempfile.gettempdir(), 'basketweave')
    if udd is None:
        udd = path.join(repo_dir, 'sessions')

    if config is not None:
        config['upload_dest_dir'] = udd
        
    app = Storage(app, upload_to=udd, tempdir=tmpdir, max_size=max_size)
 
    if pm != 'false':
        from repoze.debug.pdbpm import PostMortemDebug
        app = PostMortemDebug(app)

    #app = trace(app)
    app = StaticDelegate(app, repo_dir, cache_max_age=cache_age)
    return app
Example #3
0
import wee
import tests
from webtest import TestApp


@wee.get(r'^/$')
def index(request):
    return "the root"


@wee.get(r'^/pickles$')
def pickle(request):
    return "the pickles"


application = wee.make_app(registry=wee.PrefixRegistry('jar-of'))

class TestPrefixDispatch(tests.BaseCase):
    app = TestApp(application)

    def test_basic_dispatch(self):
        res = self.app.get('/jar-of')
        self.cmp(res.body, "the root")

        res = self.app.get('/jar-of/pickles')
        self.cmp(res.body, "the pickles")
Example #4
0
    def test_self_scoping(self):
        import scan_test
        app = TestApp(wee.make_app(module=scan_test, walk=True))
        self.cmp(app.get("/").status, "200 OK")

        self.cmp(app.get("/other").status, "200 OK")
Example #5
0
 def test_self_scoping(self):
     app = TestApp(wee.make_app(registry=wee.DispatchRegistry()))
     self.cmp(app.get("/").status, "200 OK")
Example #6
0
    return webob.Response("I'm a response")


@wee.post(r"^/$")
def postme(request):
    return "I'm a post"


class BaseCase(unittest.TestCase):
    def cmp(self, have, want):
        assert have == want, "\n%s != \n%s" %(have, want) 



reg = wee.DispatchRegistry()
application = wee.make_app(registry=reg, walk=False)

def test_reg_consitency():
    for module, patt in reg['GET'].keys():
        assert module == 'tests', "Scanning is walking more than just this module"


class TestWee(BaseCase):
    app = TestApp(application)

    def test_get(self):
        res = self.app.get("/")
        self.cmp(res.status, '200 OK')
        self.cmp(res.body, "I'm a string") 
        
        res = self.app.get("/response")
Example #7
0
    def delete(self, item_id):
        return "delete %s" %item_id


@wee.rest(r"^/wholepath/$")
class ResourceMoney(Resource):
    pass


@wee.rest(r"^/addslash")
class ResourceAddSlash(Resource):
    pass


application = wee.make_app()


class TestREST(tests.BaseCase):
    app = TestApp(application)

    def test_empty(self):
        res = self.app.get("/empty")
        
    def test_get(self):
        res = self.app.get("/")
        self.cmp(res.status, '200 OK')
        self.cmp(res.body, "You got served") 

    def test_getitem(self):
        res = self.app.get("/some_id")