def test_serves(self): whitenoise = WhiteNoise(None, autorefresh=True) whitenoise.add_files( static.resolver.resolve("warehouse:/static/dist/").abspath(), prefix="/static/", ) path, headers = ( whitenoise.find_file("/static/manifest.json").get_path_and_headers( {})) headers = dict(headers) response = pretend.stub() handler = pretend.call_recorder(lambda request: response) registry = pretend.stub(whitenoise=whitenoise) request = pretend.stub( method="GET", environ={}, path_info="/static/manifest.json", registry=registry, ) tween = static.whitenoise_tween_factory(handler, registry) resp = tween(request) assert resp.status_code == 200 assert resp.headers["Content-Type"] == "application/json" assert resp.headers["Cache-Control"] == "public, max-age=60" assert resp.headers["Vary"] == "Accept-Encoding" with open(path, "rb") as fp: assert resp.body == fp.read()
def test_serves(self): whitenoise = WhiteNoise(None, autorefresh=True) whitenoise.add_files( static.resolver.resolve("warehouse:/static/dist/").abspath(), prefix="/static/", ) path, headers = (whitenoise.find_file("/static/manifest.json") .get_path_and_headers({})) headers = dict(headers) response = pretend.stub() handler = pretend.call_recorder(lambda request: response) registry = pretend.stub(whitenoise=whitenoise) request = pretend.stub( method="GET", environ={}, path_info="/static/manifest.json", registry=registry, ) tween = static.whitenoise_tween_factory(handler, registry) resp = tween(request) assert resp.status_code == 200 assert resp.headers["Content-Type"] == "application/json" assert resp.headers["Cache-Control"] == "public, max-age=60" assert resp.headers["Vary"] == "Accept-Encoding" with open(path, "rb") as fp: assert resp.body == fp.read()