Ticket #6118: 6118.2.patch

File 6118.2.patch, 2.7 KB (added by moijes12, 9 years ago)

Made some additions.

  • twisted/web/test/test_http.py

     
    16621662        self.assertRaises(RuntimeError, request.noLongerQueued)
    16631663
    16641664
     1665    def test_noLongerQueuedRegistersPullProducer(self):
     1666        """
     1667        L{Request.noLongerQueued} registers a pull producer with transport if
     1668        there is a producer.
     1669        """
     1670        request = http.Request(DummyChannel(), True)
     1671        request.producer = DummyProducer()
     1672        request.streamingProducer = False
     1673        request.write(b"Hello")
     1674        request.noLongerQueued()
     1675        self.assertEqual([(request.producer, False)], request.transport.producers)
     1676
     1677
     1678    def test_noLongerQueuedRegistersPushProducer(self):
     1679        """
     1680        L{Request.noLongerQueued} registers a push producer with transport if
     1681        there is a producer.
     1682        """
     1683        request = http.Request(DummyChannel(), True)
     1684        request.producer = DummyProducer()
     1685        request.streamingProducer = True
     1686        request.write(b"Hello")
     1687        request.noLongerQueued()
     1688        self.assertEqual([(request.producer, True)], request.transport.producers)
     1689
     1690
     1691    def test_noLongerQueuedRegistersNoProducer(self):
     1692        """
     1693        L{Request.noLongerQueued} does not registers producer with transport if
     1694        there is no producer.
     1695        """
     1696        request = http.Request(DummyChannel(), True)
     1697        request.write(b"Hello")
     1698        request.noLongerQueued()
     1699        self.assertEqual([], request.transport.producers)
     1700
     1701
     1702    def test_noLongerQueuedCleanupIfFinished(self):
     1703        """
     1704        L{Request.noLongerQueued} calls L{Request._cleanup()} if it has
     1705        finished. This is done by checking that the content attribute is
     1706        deleted.
     1707        """
     1708        request = http.Request(DummyChannel(), True)
     1709        request.content = b"Hello"
     1710        request.gotLength(1000001)
     1711        request.finished = 1
     1712        request.noLongerQueued()
     1713        self.assertIdentical(None, request.content)
     1714
     1715
     1716    def test_noLongerQueuedWriteIfData(self):
     1717        """
     1718        L{Request.noLongerQueued} writes data to the transport if and only if
     1719        data is present. L{Request.noLongerQueued} sets the transport to the
     1720        underlying channel transport(default = TCP) which doesn't have a
     1721        getvalue method.
     1722        """
     1723        request = http.Request(DummyChannel(), True)
     1724        request.write(b"Hello")
     1725        request.noLongerQueued()
     1726        self.assertIdentical(None, getattr(request.transport,"getvalue", None))
     1727
     1728
    16651729
    16661730class MultilineHeadersTestCase(unittest.TestCase):
    16671731    """