summaryrefslogtreecommitdiff
path: root/tests/test_init.py
diff options
context:
space:
mode:
authorBert JW Regeer <bertjw@regeer.org>2020-02-02 22:36:59 -0800
committerBert JW Regeer <bertjw@regeer.org>2020-04-16 22:54:28 -0700
commiteb980ae020d9a4b16b719dd8a01737a32a5a01f2 (patch)
tree85f86cbff4bff2847c01b9d3f85dc9941ae07b3a /tests/test_init.py
parentfc4a5ebaf94a5a0a73900e86f8a55895d0204e2f (diff)
downloadwaitress-eb980ae020d9a4b16b719dd8a01737a32a5a01f2.tar.gz
Move tests to top directory
Diffstat (limited to 'tests/test_init.py')
-rw-r--r--tests/test_init.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/test_init.py b/tests/test_init.py
new file mode 100644
index 0000000..f9b91d7
--- /dev/null
+++ b/tests/test_init.py
@@ -0,0 +1,51 @@
+import unittest
+
+
+class Test_serve(unittest.TestCase):
+ def _callFUT(self, app, **kw):
+ from waitress import serve
+
+ return serve(app, **kw)
+
+ def test_it(self):
+ server = DummyServerFactory()
+ app = object()
+ result = self._callFUT(app, _server=server, _quiet=True)
+ self.assertEqual(server.app, app)
+ self.assertEqual(result, None)
+ self.assertEqual(server.ran, True)
+
+
+class Test_serve_paste(unittest.TestCase):
+ def _callFUT(self, app, **kw):
+ from waitress import serve_paste
+
+ return serve_paste(app, None, **kw)
+
+ def test_it(self):
+ server = DummyServerFactory()
+ app = object()
+ result = self._callFUT(app, _server=server, _quiet=True)
+ self.assertEqual(server.app, app)
+ self.assertEqual(result, 0)
+ self.assertEqual(server.ran, True)
+
+
+class DummyServerFactory(object):
+ ran = False
+
+ def __call__(self, app, **kw):
+ self.adj = DummyAdj(kw)
+ self.app = app
+ self.kw = kw
+ return self
+
+ def run(self):
+ self.ran = True
+
+
+class DummyAdj(object):
+ verbose = False
+
+ def __init__(self, kw):
+ self.__dict__.update(kw)