示例#1
0
 def test_registerProducerTwiceFails(self):
     """
     Calling L{Request.registerProducer} when a producer is already
     registered raises ValueError.
     """
     req = http.Request(DummyChannel(), None)
     req.registerProducer(DummyProducer(), True)
     self.assertRaises(ValueError, req.registerProducer, DummyProducer(),
                       True)
示例#2
0
 def test_registerProducerWhenQueuedPausesPushProducer(self):
     """
     Calling L{Request.registerProducer} with an IPushProducer when the
     request is queued pauses the producer.
     """
     req = http.Request(DummyChannel(), True)
     producer = DummyProducer()
     req.registerProducer(producer, True)
     self.assertEquals(['pause'], producer.events)
示例#3
0
 def test_registerProducerWhenNotQueuedRegistersPullProducer(self):
     """
     Calling L{Request.registerProducer} with an IPullProducer when the
     request is not queued registers the producer as a pull producer on the
     request's transport.
     """
     req = http.Request(DummyChannel(), False)
     producer = DummyProducer()
     req.registerProducer(producer, False)
     self.assertEquals([(producer, False)], req.transport.producers)
示例#4
0
 def test_registerProducerWhenQueuedDoesntPausePullProducer(self):
     """
     Calling L{Request.registerProducer} with an IPullProducer when the
     request is queued does not pause the producer, because it doesn't make
     sense to pause a pull producer.
     """
     req = http.Request(DummyChannel(), True)
     producer = DummyProducer()
     req.registerProducer(producer, False)
     self.assertEquals([], producer.events)
示例#5
0
 def test_registerProducerWhenQueuedDoesntRegisterPullProducer(self):
     """
     Calling L{Request.registerProducer} with an IPullProducer when the
     request is queued does not register the producer on the request's
     transport.
     """
     self.assertIdentical(
         None, getattr(http.StringTransport, 'registerProducer', None),
         "StringTransport cannot implement registerProducer for this test "
         "to be valid.")
     req = http.Request(DummyChannel(), True)
     producer = DummyProducer()
     req.registerProducer(producer, False)
     # This is a roundabout assertion: http.StringTransport doesn't
     # implement registerProducer, so Request.registerProducer can't have
     # tried to call registerProducer on the transport.
     self.assertIsInstance(req.transport, http.StringTransport)