Skip to content

Commit

Permalink
Merge pull request #1302 from thingsboard/tests-improvement
Browse files Browse the repository at this point in the history
Tests improvement
  • Loading branch information
imbeacon authored Feb 20, 2024
2 parents 0021af2 + f6190eb commit 9dda62b
Show file tree
Hide file tree
Showing 169 changed files with 6,462 additions and 703 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ __pycache__
/thingsboard_gateway/config/
/venv/
/for_build/etc/thingsboard-gateway/config/
/thingsboard_gateway/logs/
/tests/storage/
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ def __init__(self, gateway, config, connector_type):
'MessagesSent': 0} # Dictionary, will save information about count received and sent messages.
self.__config = config # Save configuration from the configuration file.
self.__gateway = gateway # Save gateway object, we will use some gateway methods for adding devices and saving data from them.
self.setName(self.__config.get("name",
"Custom %s connector " % self.get_name() + ''.join(
choice(ascii_lowercase) for _ in range(5)))) # get from the configuration or create name for logs.
self.name = self.__config.get("name",
"Custom %s connector " % self.get_name() + ''.join(choice(ascii_lowercase) for _ in range(5))) # get from the configuration or create name for logs.
log.info("Starting Custom %s connector", self.get_name()) # Send message to logger
self.daemon = True # Set self thread as daemon
self.stopped = True # Service variable for check state
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ mmh3
protobuf<=3.20.0
cachetools
cryptography==3.4.*
tb-mqtt-client>=1.5
tb-mqtt-client>=1.7.1
service-identity
29 changes: 29 additions & 0 deletions tests/base_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import logging
from sys import stdout
from unittest import TestCase
from tests.test_utils.gateway_device_util import GatewayDeviceUtil

logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(module)s - %(lineno)d - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')

LOG = logging.getLogger("TEST")
LOG.level = logging.DEBUG
stream_handler = logging.StreamHandler(stdout)
LOG.addHandler(stream_handler)


class BaseTest(TestCase):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.log = LOG

@classmethod
def setUpClass(cls):
GatewayDeviceUtil.get_gateway_device()

@classmethod
def tearDownClass(cls):
GatewayDeviceUtil.delete_gateway_device()
assert GatewayDeviceUtil.GATEWAY_DEVICE is None
Empty file added tests/blackbox/__init__.py
Empty file.
Empty file.
Empty file.
Loading

0 comments on commit 9dda62b

Please sign in to comment.