Ejemplo n.º 1
0
def test_serve_file(image_dir):
    path = static_dir + "/logos/logo-en.png"

    assert coverlib.read_file('/dev/null') == ''
    assert coverlib.read_file(path) == open(path).read()

    assert coverlib.read_file(path + ":10:20") == open(path).read()[10:10 + 20]
Ejemplo n.º 2
0
def test_serve_file():
    path = static_dir + "/logos/logo-en.png"
        
    assert coverlib.read_file('/dev/null') == ''
    assert coverlib.read_file(path) == open(path).read()

    assert coverlib.read_file(path + ":10:20") == open(path).read()[10:10+20] 
Ejemplo n.º 3
0
 def notfound():
     if config.default_image and i.default.lower() != "false" and not is_valid_url(i.default):
         return read_file(config.default_image)
     elif is_valid_url(i.default):
         raise web.seeother(i.default)
     else:
         raise web.notfound("")
Ejemplo n.º 4
0
 def notfound():
     if key in ["id", "olid"] and config.get("upstream_base_url"):
         # this is only used in development
         base = web.rstrips(config.upstream_base_url, "/")
         raise web.redirect(base + web.ctx.fullpath)
     elif config.default_image and i.default.lower(
     ) != "false" and not is_valid_url(i.default):
         return read_file(config.default_image)
     elif is_valid_url(i.default):
         raise web.seeother(i.default)
     else:
         raise web.notfound("")