SIENTIAPDE-1205

Refactor OpcRepository and update tests for async handling

- Removed the shutdown method from OpcRepository and adjusted the disconnect logic.
- Updated tests in test_activities.py and test_opc.py to support async shutdown functionality.
- Enhanced test cases in test_opc_repository.py to ensure proper async behavior and error handling in OpcRepository methods.
This commit is contained in:
vitor-aignosi
2025-08-28 10:21:20 -03:00
parent fc799de42e
commit 7f3ecc9add
5 changed files with 260 additions and 131 deletions

View File

@@ -158,16 +158,6 @@ class OpcRepository():
f"Failed to disconnect from OPC server: {e}", self.metadata)
self.client = None
def shutdown(self):
"""
Disconnects from the OPC server when the object is destroyed.
"""
try:
asyncio.run(self.disconnect())
except Exception as e:
self.logger.custom_error(
f"Error in destructor: {e}", self.metadata)
async def validate_connection(self) -> tuple[bool, dict[str, Any]]:
"""
Validates the connection to the OPC server using protocol state checking.