blob: dd430e9961e38302bdcbaf8a8016249c1acb9605 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
from contextlib import contextmanager
from wsgiref.validate import validator
from paste import open_store
from ..common_wsgi import call_app
def test_open_store(monkeypatch):
db_path = "test_db_path"
store = object()
@contextmanager
def store_open(path):
assert path == db_path
yield store
@validator
@open_store
@validator
def app(environ, start_response):
assert "paste.store" in environ
assert environ["paste.store"] == store
start_response("200 OK", [("Content-Type", "text/plain")])
return [b"Hello, World!"]
monkeypatch.setattr("paste.store.open", store_open)
response = call_app(app, environ={"PASTE_DB": db_path})
assert response.status == "200 OK"
assert response.data == b"Hello, World!"
assert ("Content-Type", "text/plain") in response.headers
|