SIENTIAPDE-1314
Refactor OPC Write Method and Comment Out Error Handling Logic - Reformatted the `write_opc_data` method for improved readability by adjusting its signature. - Commented out the error handling logic in `OpcRepository` related to disconnection due to multiple errors, preserving the original functionality for future reference. - Updated tests to reflect the commented-out error handling, ensuring clarity in the testing process.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import json
|
||||
from datetime import datetime
|
||||
from unittest.mock import ANY, AsyncMock, MagicMock, Mock, call, patch
|
||||
from unittest.mock import ANY, AsyncMock, MagicMock, Mock, patch
|
||||
|
||||
import pytest
|
||||
from asyncua.crypto.security_policies import SecurityPolicyBasic256
|
||||
@@ -236,22 +236,22 @@ async def test_validate_connection_none_client(opc_repository):
|
||||
opc_repository.connect.assert_called_once()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_validate_connection_error_count_disconnect_error(opc_repository):
|
||||
opc_repository.error_count = 6
|
||||
opc_repository.client = AsyncMock()
|
||||
opc_repository.disconnect = AsyncMock(side_effect=Exception('Test error'))
|
||||
opc_repository.connect = AsyncMock(return_value=(True, {}))
|
||||
# @pytest.mark.asyncio
|
||||
# async def test_validate_connection_error_count_disconnect_error(opc_repository):
|
||||
# opc_repository.error_count = 6
|
||||
# opc_repository.client = AsyncMock()
|
||||
# opc_repository.disconnect = AsyncMock(side_effect=Exception('Test error'))
|
||||
# opc_repository.connect = AsyncMock(return_value=(True, {}))
|
||||
|
||||
response = await opc_repository.validate_connection()
|
||||
assert response == opc_repository.connect.return_value
|
||||
opc_repository.disconnect.assert_called_once()
|
||||
opc_repository.connect.assert_called_once()
|
||||
opc_repository.logger.custom_error.assert_has_calls(
|
||||
[
|
||||
call('Failed to disconnect from OPC server: Test error', ANY),
|
||||
]
|
||||
)
|
||||
# response = await opc_repository.validate_connection()
|
||||
# assert response == opc_repository.connect.return_value
|
||||
# opc_repository.disconnect.assert_called_once()
|
||||
# opc_repository.connect.assert_called_once()
|
||||
# opc_repository.logger.custom_error.assert_has_calls(
|
||||
# [
|
||||
# call('Failed to disconnect from OPC server: Test error', ANY),
|
||||
# ]
|
||||
# )
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user