Skip to content

Commit

Permalink
Fixed mocking of handler
Browse files Browse the repository at this point in the history
  • Loading branch information
imbeacon committed Dec 5, 2024
1 parent bc11eff commit 4fac5bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion tests/integration/connectors/can/test_can_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from thingsboard_gateway.gateway.entities.report_strategy_config import ReportStrategyConfig
from thingsboard_gateway.gateway.entities.telemetry_entry import TelemetryEntry
from thingsboard_gateway.gateway.tb_gateway_service import TBGatewayService
from thingsboard_gateway.tb_utility.tb_handler import TBRemoteLoggerHandler
from thingsboard_gateway.tb_utility.tb_logger import TbLogger, init_logger

try :
Expand Down Expand Up @@ -66,6 +67,8 @@ def setUp(self):
super().setUp()
self.bus = self._create_bus()
self.gateway = Mock(spec=TBGatewayService)
self.gateway.remote_handler = Mock(spec=TBRemoteLoggerHandler)
self.gateway.remote_handler.level = logging.DEBUG
self.tb_logger = Mock(spec=TbLogger)
self.connector = None
self.config = None
Expand All @@ -92,7 +95,7 @@ def _create_connector(self, config_file_name):
self.connector.open()
sleep(1) # some time to init
except Exception as e:
print(e)
raise e


class CanConnectorPollingTests(CanConnectorTestsBase):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

import logging
# Copyright 2022. ThingsBoard
# #
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -24,6 +24,7 @@

from thingsboard_gateway.gateway.tb_gateway_service import TBGatewayService
from thingsboard_gateway.gateway.tb_gateway_service import DEFAULT_CONNECTORS
from thingsboard_gateway.tb_utility.tb_handler import TBRemoteLoggerHandler
from thingsboard_gateway.tb_utility.tb_loader import TBModuleLoader


Expand All @@ -35,6 +36,8 @@ def setUp(self):
super().setUp()
self.mock_logger = patch('thingsboard_gateway.tb_utility.tb_logger.TbLogger').start()
self.gateway = Mock(spec=TBGatewayService)
self.gateway.remote_handler = Mock(spec=TBRemoteLoggerHandler)
self.gateway.remote_handler.level = logging.DEBUG
self.gateway.log = self.mock_logger
self.connector = None
self.config = None
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/connectors/modbus/test_modbus_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from thingsboard_gateway.connectors.modbus.entities.bytes_uplink_converter_config import BytesUplinkConverterConfig
from thingsboard_gateway.gateway.tb_client import TBClient
from thingsboard_gateway.tb_utility.tb_handler import TBRemoteLoggerHandler
from thingsboard_gateway.tb_utility.tb_logger import TbLogger

try:
Expand All @@ -35,6 +36,8 @@ def setUp(self) -> None:
super().setUp()
self.tb_client = Mock(spec=TBClient)
self.gateway = Mock(spec=TBGatewayService)
self.gateway.remote_handler = Mock(spec=TBRemoteLoggerHandler)
self.gateway.remote_handler.level = logging.DEBUG
self.gateway.tb_client = self.tb_client
self.tb_logger = Mock(spec=TbLogger)
self.gateway.get_devices.return_value = []
Expand Down

0 comments on commit 4fac5bf

Please sign in to comment.