def test_populate_closed_stream(self): stream = SendStream(1) stream.close() assert stream.closed stream.populate(range(10)) assert stream.queue.qsize() == 1
def test_stream_closed(self): stream = SendStream(1) max_bytes = 10 chunk_size = 5 stream.close() assert list(stream.read(max_bytes, chunk_size)) == []
def test_error_on_queue(self, generate_messages): stream = SendStream(1) stream.populate(generate_messages(count=2, length=20)) error = GrpcError("boom", "details", "error string") stream.close(error) with pytest.raises(GrpcError): stream.flush_queue_to_buffer()
def test_stream_closed_with_error(self): stream = SendStream(1) error = GrpcError("boom", "details", "error string") stream.close(error) max_bytes = 10 chunk_size = 5 with pytest.raises(GrpcError): next(stream.read(max_bytes, chunk_size))