SIENTIAPDE-1646

Harden retrain merge and OPC write against silent failures

- pandas merge now uses validate='one_to_one' so duplicated timestamps
  from wrapper.retrain fail loudly instead of silently multiplying rows
- OPC write_data raises OpcClientNotInitializedError instead of a bare
  assert when client is torn down between validation and write, so
  callers get a reported error instead of an AssertionError
- add regression test covering the torn-down client path

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 12:27:17 -03:00
parent 5c3c9292fc
commit f323da7b56
3 changed files with 35 additions and 11 deletions

View File

@@ -444,6 +444,22 @@ def test_write_data_get_node_failed(opc_repository):
assert error_data['attachment_content'] is not None
def test_write_data_without_client_fails_as_get_node_error(opc_repository):
"""A client torn down between validation and the write is reported, not asserted away."""
opc_repository.validate_connection = MagicMock(return_value=(True, {}))
opc_repository.client = None
is_success, error_data = opc_repository.write_data(
'ns=2;s=TestNode', 42.0, 'float', metadata['metadata']
)
assert is_success is False
assert error_data['notification_id'] == f'OPC_WRITE_GET_NODE_ERROR_{opc_repository.id}'
assert 'OPC client is not initialized' in error_data['message']
last_call = opc_repository.emit_metric_sync.call_args_list[-1]
assert last_call.args[1]['result'] == 'GetNodeError:OpcClientNotInitializedError'
def test_write_data_invalid_data_type(opc_repository, mock_client):
opc_repository.validate_connection = MagicMock(return_value=(True, {}))
opc_repository.client = mock_client