From 5eacce6f59214aec69eebcfbe4081f1f3ee4dd2b Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Thu, 22 Dec 2011 03:15:39 -0500 Subject: get channel back up to 100 percent after integration test disable --- waitress/channel.py | 2 +- waitress/tests/test_channel.py | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/waitress/channel.py b/waitress/channel.py index 702feae..66cccb9 100644 --- a/waitress/channel.py +++ b/waitress/channel.py @@ -62,7 +62,7 @@ class HTTPServerChannel(asyncore.dispatcher, object): adj=None, map=None, # test shim ): - if map is None: + if map is None: # pragma: no cover map = asyncore.socket_map self.addr = addr if adj is None: diff --git a/waitress/tests/test_channel.py b/waitress/tests/test_channel.py index f388039..308e798 100644 --- a/waitress/tests/test_channel.py +++ b/waitress/tests/test_channel.py @@ -333,6 +333,39 @@ class TestHTTPServerChannel(unittest.TestCase): self.assertEqual(inst.server.tasks, [inst]) self.assertEqual(len(inst.tasks), 1) + def test_received_preq_not_completed(self): + inst, sock, map = self._makeOneWithMap() + inst.server = DummyServer() + preq = DummyParser() + inst.proto_request = preq + preq.completed = False + preq.empty = True + inst.received('GET / HTTP/1.1\n\n') + self.assertEqual(inst.server.tasks, []) + + def test_received_preq_completed(self): + inst, sock, map = self._makeOneWithMap() + inst.server = DummyServer() + preq = DummyParser() + inst.proto_request = preq + preq.completed = True + preq.empty = True + inst.received('GET / HTTP/1.1\n\n') + self.assertEqual(inst.proto_request, None) + self.assertEqual(inst.server.tasks, []) + + def test_received_preq_completed_n_lt_data(self): + inst, sock, map = self._makeOneWithMap() + inst.server = DummyServer() + preq = DummyParser() + inst.proto_request = preq + preq.completed = True + preq.empty = True + preq.retval = 1 + inst.received('GET / HTTP/1.1\n\n') + self.assertEqual(inst.proto_request, None) + self.assertEqual(inst.server.tasks, [inst]) + def test_handle_request(self): req = DummyParser() inst, sock, map = self._makeOneWithMap() @@ -487,6 +520,13 @@ class DummyServer(object): class DummyParser(object): version = 1 + data = None + completed = True + empty = False + retval = 1000 + def received(self, data): + self.data = data + return self.retval class DummyTask(object): serviced = False -- cgit v1.2.1