SIENTIAPDE-1199

Update tests in Gates and OpcRepository to enhance logging and include metadata

- Removed unnecessary debug assertion in the Gates activity test for format prediction.
- Updated the test for last timestamp with no data to include a metadata dictionary.
- Modified OpcRepository tests to utilize custom_error logging with metadata for improved error context.
This commit is contained in:
vitor-aignosi
2025-08-21 08:56:18 -03:00
parent 39ff7e2625
commit a3b642dbef
2 changed files with 7 additions and 6 deletions

View File

@@ -344,7 +344,6 @@ async def test_format_prediction(gates_activity):
assert result['prediction_confidence'] == {0: 0.9}
assert result['prediction_status'] == {0: 'Good'}
assert result['comments'] == {0: ""}
gates_activity.debug.assert_called()
@mark.asyncio
@@ -393,7 +392,8 @@ async def test_get_last_timestamp_with_data(gates_activity):
async def test_get_last_timestamp_no_data(gates_activity):
# Arrange
input_data = {
'data': {}
'data': {},
**metadata
}
# Act

View File

@@ -139,8 +139,9 @@ def test_disconnect_error(opc_repository, mock_client):
mock_client.disconnect.side_effect = Exception("Test error")
opc_repository.disconnect()
opc_repository.logger.error.assert_called_once_with(
"Failed to disconnect from OPC server: Test error"
opc_repository.logger.custom_error.assert_called_once_with(
"Failed to disconnect from OPC server: Test error",
ANY
)
assert opc_repository.client is None
@@ -163,9 +164,9 @@ def test_validate_connection_error_count_disconnect_error(opc_repository):
assert response == opc_repository.connect.return_value
opc_repository.disconnect.assert_called_once()
opc_repository.connect.assert_called_once()
opc_repository.logger.error.assert_has_calls(
opc_repository.logger.custom_error.assert_has_calls(
[
call("Failed to disconnect from OPC server: Test error"),
call("Failed to disconnect from OPC server: Test error", ANY),
]
)