Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,604 changes: 1,251 additions & 353 deletions sonic-bmcctld/scripts/bmcctld

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion sonic-bmcctld/tests/mock_swsscommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
RedisPipeline,
STATE_DB,
CONFIG_DB,
reset_mock_db,
)

5 changes: 5 additions & 0 deletions sonic-bmcctld/tests/mocked_libs/grpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Minimal gRPC import surface; transport tests inject their own client API."""


class RpcError(Exception):
pass
1 change: 1 addition & 0 deletions sonic-bmcctld/tests/mocked_libs/sonic_grpc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""gNOI import stubs for isolated daemon unit tests."""
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""gNOI import stubs for isolated daemon unit tests."""
6 changes: 6 additions & 0 deletions sonic-bmcctld/tests/mocked_libs/sonic_grpc/gnoi/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Placeholder; requester tests must inject the client they exercise."""


class GnoiClient:
def __init__(self, *args, **kwargs):
raise AssertionError("GnoiClient must be mocked by the unit test")
7 changes: 7 additions & 0 deletions sonic-bmcctld/tests/mocked_libs/sonic_grpc/gnoi/system_pb2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Protocol constants used by report-classification unit tests."""

HALT = 3


class RebootStatus:
STATUS_SUCCESS = 1
13 changes: 13 additions & 0 deletions sonic-bmcctld/tests/mocked_libs/sonic_py_common/device_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Minimal device_info surface used by bmcctld unit tests."""


def is_switch_bmc():
return False


def get_platform_json_data():
return None


def get_path_to_platform_dir():
return ""
12 changes: 11 additions & 1 deletion sonic-bmcctld/tests/mocked_libs/swsscommon/swsscommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,22 @@ def isInit():
STATE_DB = ''
CONFIG_DB = ''

_MOCK_DATABASE = {}


def reset_mock_db():
_MOCK_DATABASE.clear()


class Table:
def __init__(self, *argv):
self.db_or_pipe = argv[0] if argv else None
self.table_name = argv[1] if len(argv) > 1 else ''
self.mock_dict = {}
if self.db_or_pipe is None:
self.mock_dict = {}
else:
self.mock_dict = _MOCK_DATABASE.setdefault(
(self.db_or_pipe, self.table_name), {})

def _del(self, key):
if key in self.mock_dict:
Expand Down
5,631 changes: 5,404 additions & 227 deletions sonic-bmcctld/tests/test_bmcctld.py

Large diffs are not rendered by default.

Loading