diff --git a/nilmdb/client/client.py b/nilmdb/client/client.py index c82e000..9fe3c6a 100644 --- a/nilmdb/client/client.py +++ b/nilmdb/client/client.py @@ -331,7 +331,7 @@ class StreamInserter(object): # Send the block once we have enough data if self._block_len >= maxdata: self._send_block(final = False) - if self._block_len >= self._max_data_after_send: # pragma: no cover + if self._block_len >= self._max_data_after_send: raise ValueError("too much data left over after trying" " to send intermediate block; is it" " missing newlines or malformed?") diff --git a/tests/test_client.py b/tests/test_client.py index 38424ac..3f2a5e1 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -571,6 +571,12 @@ class TestClient(object): ctx.finalize() ctx.insert(b"# this is super long" * 100) + # override _max_data_after_send to trigger ValueError on a + # long nonterminated line + ctx._max_data_after_send = 1000 + with assert_raises(ValueError): + ctx.insert(b"# this is super long" * 100) + with assert_raises(ClientError): with client.stream_insert_context("/context/test", 1000, 2000) as ctx: