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:
@@ -344,7 +344,6 @@ async def test_format_prediction(gates_activity):
|
|||||||
assert result['prediction_confidence'] == {0: 0.9}
|
assert result['prediction_confidence'] == {0: 0.9}
|
||||||
assert result['prediction_status'] == {0: 'Good'}
|
assert result['prediction_status'] == {0: 'Good'}
|
||||||
assert result['comments'] == {0: ""}
|
assert result['comments'] == {0: ""}
|
||||||
gates_activity.debug.assert_called()
|
|
||||||
|
|
||||||
|
|
||||||
@mark.asyncio
|
@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):
|
async def test_get_last_timestamp_no_data(gates_activity):
|
||||||
# Arrange
|
# Arrange
|
||||||
input_data = {
|
input_data = {
|
||||||
'data': {}
|
'data': {},
|
||||||
|
**metadata
|
||||||
}
|
}
|
||||||
|
|
||||||
# Act
|
# Act
|
||||||
|
|||||||
@@ -139,8 +139,9 @@ def test_disconnect_error(opc_repository, mock_client):
|
|||||||
mock_client.disconnect.side_effect = Exception("Test error")
|
mock_client.disconnect.side_effect = Exception("Test error")
|
||||||
opc_repository.disconnect()
|
opc_repository.disconnect()
|
||||||
|
|
||||||
opc_repository.logger.error.assert_called_once_with(
|
opc_repository.logger.custom_error.assert_called_once_with(
|
||||||
"Failed to disconnect from OPC server: Test error"
|
"Failed to disconnect from OPC server: Test error",
|
||||||
|
ANY
|
||||||
)
|
)
|
||||||
assert opc_repository.client is None
|
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
|
assert response == opc_repository.connect.return_value
|
||||||
opc_repository.disconnect.assert_called_once()
|
opc_repository.disconnect.assert_called_once()
|
||||||
opc_repository.connect.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),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user