From 3ab9e05442636dd9c8572fd99a9b4d4823b200d3 Mon Sep 17 00:00:00 2001 From: Joe Kaufeld Date: Mon, 26 Aug 2024 01:56:31 -0400 Subject: [PATCH] :white_check_mark: add helpers --- spiderweb/tests/helpers.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 spiderweb/tests/helpers.py diff --git a/spiderweb/tests/helpers.py b/spiderweb/tests/helpers.py new file mode 100644 index 0000000..7948c1a --- /dev/null +++ b/spiderweb/tests/helpers.py @@ -0,0 +1,28 @@ +from wsgiref.util import setup_testing_defaults + +from peewee import SqliteDatabase + +from spiderweb import SpiderwebRouter + + +class StartResponse: + def __init__(self): + self.status = None + self.headers = None + + def __call__(self, status, headers): + self.status = status + self.headers = headers + + def get_headers(self): + return {h[0]: h[1] for h in self.headers} + + +def setup(): + environ = {} + setup_testing_defaults(environ) + return ( + SpiderwebRouter(db=SqliteDatabase("spiderweb-tests.db")), + environ, + StartResponse(), + ) \ No newline at end of file