diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 4119e99..dde307b 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -1,13 +1,13 @@ from unittest.mock import AsyncMock, MagicMock -from pytest import fixture +import pytest -@fixture +@pytest.fixture def reader_double(): """Factory of OPC reader doubles holding subscriptions for the given slots. - Like the real readers (ServerReader, OpcManager), `subscriptions` is keyed by slot + Like the real ServerReader, `subscriptions` is keyed by slot and `unsubscribe` drops the slot from it. """ diff --git a/tests/unit/connection/test_certs.py b/tests/unit/connection/test_certs.py index 84a686a..9f392a3 100644 --- a/tests/unit/connection/test_certs.py +++ b/tests/unit/connection/test_certs.py @@ -46,7 +46,8 @@ async def test_local_files_keep_the_object_extension(tmp_path): cert, key = await provider.fetch(certificate(ext='der')) - assert cert.endswith('cert.der') and key.endswith('key.der') + assert cert.endswith('cert.der') + assert key.endswith('key.der') @pytest.mark.asyncio @@ -61,9 +62,10 @@ async def test_local_files_keep_the_object_extension(tmp_path): ) async def test_fetch_of_an_incomplete_certificate_raises_clear_error(tmp_path, broken): provider, minio = _provider(tmp_path) + incomplete = {**certificate(), **broken} with pytest.raises(CertificateNotConfiguredError, match='opc_certificates|certificate_id'): - await provider.fetch({**certificate(), **broken}) + await provider.fetch(incomplete) minio.download_file.assert_not_awaited() diff --git a/tests/unit/connection/test_clock.py b/tests/unit/connection/test_clock.py index f947d86..30f60cf 100644 --- a/tests/unit/connection/test_clock.py +++ b/tests/unit/connection/test_clock.py @@ -5,4 +5,6 @@ def test_elapsed_is_non_negative_and_monotonic(): clk = MonotonicClock() a = clk.elapsed() b = clk.elapsed() - assert a >= 0 and b >= a # never negative even if wall clock jumps back + # never negative even if wall clock jumps back + assert a >= 0 + assert b >= a diff --git a/tests/unit/engines/test_write.py b/tests/unit/engines/test_write.py index d595d67..2d2aded 100644 --- a/tests/unit/engines/test_write.py +++ b/tests/unit/engines/test_write.py @@ -346,8 +346,10 @@ async def test_write_error_logs_the_reason_and_sets_the_model_status(): await eng.write(base_cmd()) logged = eng.logger.error.call_args.args[0] - assert 'RuntimeError' in logged and 'BadWriteNotSupported' in logged - assert 'addr=ns=2;i=5' in logged and 'model_id=m1' in logged + assert 'RuntimeError' in logged + assert 'BadWriteNotSupported' in logged + assert 'addr=ns=2;i=5' in logged + assert 'model_id=m1' in logged status_call = next( c for c in eng.emit_metric.await_args_list diff --git a/tests/unit/io/test_data_sink_status.py b/tests/unit/io/test_data_sink_status.py index 590796a..01324ca 100644 --- a/tests/unit/io/test_data_sink_status.py +++ b/tests/unit/io/test_data_sink_status.py @@ -58,7 +58,8 @@ async def test_update_write_status_targets_model_row_with_precedence(): assert sql.startswith('UPDATE sientia_data.pred_m1 SET write_status=') assert 'CASE sientia_data.pred_m1.write_status WHEN' in sql # values must be bound params, never interpolated into the SQL text itself - assert '2026-07-13T00:00:00Z' not in sql and "'ok'" not in sql + assert '2026-07-13T00:00:00Z' not in sql + assert "'ok'" not in sql assert compiled.params['write_status'] == 'ok' assert '2026-07-13T00:00:00Z' in compiled.params.values() assert _outcome_metric(sink) == 'updated'