Skip to content

Commit b022801

Browse files
Refactored for graceful shutdown
1 parent ecd68c9 commit b022801

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

sonic-chassisd/tests/test_chassisd.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,32 @@
2626
mocked_libs_path = os.path.join(test_path, 'mocked_libs')
2727
sys.path.insert(0, mocked_libs_path)
2828

29+
# --------------------------------------------------------------------
30+
# SonicV2Connector
31+
# --------------------------------------------------------------------
32+
class _DummySonicV2Connector(object):
33+
def __init__(self, use_unix_socket_path=True, **kwargs):
34+
self.use_unix_socket_path = use_unix_socket_path
35+
def connect(self, db_name): # no-op
36+
return None
37+
def close(self): # no-op
38+
return None
39+
40+
# Try to attach to whichever mocked swsscommon the testbed uses
41+
try:
42+
import swsscommon as _swsscommon_mod
43+
if not hasattr(_swsscommon_mod, "SonicV2Connector"):
44+
_swsscommon_mod.SonicV2Connector = _DummySonicV2Connector
45+
except Exception:
46+
pass
47+
48+
try:
49+
import tests.mock_swsscommon as _tests_swsscommon_mod
50+
if not hasattr(_tests_swsscommon_mod, "SonicV2Connector"):
51+
_tests_swsscommon_mod.SonicV2Connector = _DummySonicV2Connector
52+
except Exception:
53+
pass
54+
2955
modules_path = os.path.dirname(test_path)
3056
scripts_path = os.path.join(modules_path, "scripts")
3157
sys.path.insert(0, modules_path)

0 commit comments

Comments
 (0)