mirror of
https://github.com/ArchiveBox/ArchiveBox
synced 2024-11-10 14:44:18 +00:00
741ff5f1a8
Changes ./bin/test.sh to pass command line options to pytest, and default to only running tests in the tests/ directory instead of everywhere excluding a few directories which is more error-prone. Also keeps the mock_server used in testing quiet so access log entries don't appear on stdout.
53 lines
1.7 KiB
Python
53 lines
1.7 KiB
Python
from os import getcwd
|
|
from pathlib import Path
|
|
|
|
from bottle import route, run, static_file, response, redirect
|
|
|
|
@route("/")
|
|
def index():
|
|
return "Hello"
|
|
|
|
@route("/static/<filename>")
|
|
def static_path(filename):
|
|
template_path = Path.cwd().resolve() / "tests/mock_server/templates"
|
|
response = static_file(filename, root=template_path)
|
|
return response
|
|
|
|
@route("/static_no_content_type/<filename>")
|
|
def static_no_content_type(filename):
|
|
template_path = Path.cwd().resolve() / "tests/mock_server/templates"
|
|
response = static_file(filename, root=template_path)
|
|
response.set_header("Content-Type", "")
|
|
return response
|
|
|
|
@route("/static/headers/<filename>")
|
|
def static_path_with_headers(filename):
|
|
template_path = Path.cwd().resolve() / "tests/mock_server/templates"
|
|
response = static_file(filename, root=template_path)
|
|
response.add_header("Content-Language", "en")
|
|
response.add_header("Content-Script-Type", "text/javascript")
|
|
response.add_header("Content-Style-Type", "text/css")
|
|
return response
|
|
|
|
@route("/static/400/<filename>", method="HEAD")
|
|
def static_400(filename):
|
|
template_path = Path.cwd().resolve() / "tests/mock_server/templates"
|
|
response = static_file(filename, root=template_path)
|
|
response.status = 400
|
|
response.add_header("Status-Code", "400")
|
|
return response
|
|
|
|
@route("/static/400/<filename>", method="GET")
|
|
def static_200(filename):
|
|
template_path = Path.cwd().resolve() / "tests/mock_server/templates"
|
|
response = static_file(filename, root=template_path)
|
|
response.add_header("Status-Code", "200")
|
|
return response
|
|
|
|
@route("/redirect/headers/<filename>")
|
|
def redirect_to_static(filename):
|
|
redirect(f"/static/headers/$filename")
|
|
|
|
|
|
def start():
|
|
run(host='localhost', port=8080, quiet=True)
|