def test_splits_chunks(self):
        key = ["1","2"]
        def verify((results, failures)):
            results = filter(None, results)
            nt.assert_equal(failures,[])
            nt.assert_equal(set(results), set(key))

        all_in_one = "%s" % "\r\n".join(key)
        self.startTestServer([all_in_one],0, add_delim=False)
        iterator = txhttpstream.getStreamedPagesIterator("http://localhost:8080")
        return self._consume_iterator(iterator).addCallback(verify)
    def test_get_chunk_coiterate(self):
        chunks = ["hej %d" % i for i in range(0,10)]
        self.startTestServer(chunks,0)

        def verify((received_chunks, failures)):
            nt.assert_equal(failures, [])
            key = set(chunks)
            key.add(None)
            nt.assert_equal(key, set(received_chunks))

        iterator = txhttpstream.getStreamedPagesIterator("http://localhost:8080")
        return self._consume_iterator(iterator).addCallback(verify)
 def test_timeout(self):
     self.startTestServer([],1)
     iterator = txhttpstream.getStreamedPagesIterator("http://localhost:8080", timeout=0.01)
     return self._consume_iterator(iterator).addCallback(self._verify_failures, defer.TimeoutError)
 def test_dns_lookup_error(self):
     iterator = txhttpstream.getStreamedPagesIterator("http://jklasdfljkweljkewjklfljkwl")
     return self._consume_iterator(iterator).addCallback(self._verify_failures, error.DNSLookupError)
 def test_connection_error(self):
     iterator = txhttpstream.getStreamedPagesIterator("http://localhost:8080")
     return self._consume_iterator(iterator).addCallback(self._verify_failures, error.ConnectionRefusedError)