Skip to content

Commit b3a3a4b

Browse files
Fixing test failures
1 parent 52e47a9 commit b3a3a4b

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

tests/chassis_modules_test.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,10 @@ def is_transition_timed_out(db, chassis_module_name):
123123
sys.modules['sonic_py_common.syslogger'] = mock.Mock()
124124

125125
# Create a mock SysLogger class
126+
127+
126128
class MockSysLogger:
127-
def __init__(self, identifier):
129+
def __init__(self, identifier=None):
128130
self.identifier = identifier
129131

130132
def log_info(self, message):
@@ -139,6 +141,7 @@ def log_warning(self, message):
139141
def log_notice(self, message):
140142
pass
141143

144+
142145
sys.modules['sonic_py_common.syslogger'].SysLogger = MockSysLogger
143146

144147
show_linecard0_shutdown_output="""\
@@ -293,6 +296,7 @@ def _stub_state_conn(row=None):
293296
row = {}
294297
return SimpleNamespace(STATE_DB=6, get_all=lambda _db, _key: row)
295298

299+
296300
# Mock StateDBHelper class used in chassis_modules.py
297301
class MockStateDBHelper:
298302
def __init__(self, sonic_db):
@@ -368,21 +372,23 @@ def test_config_shutdown_module(self):
368372
with mock.patch("config.chassis_modules.StateDBHelper", new=MockStateDBHelper):
369373
runner = CliRunner()
370374
db = Db()
371-
result = runner.invoke(config.config.commands["chassis"].commands["modules"].commands["shutdown"], ["LINE-CARD0"], obj=db)
375+
result = runner.invoke(config.config.commands["chassis"].commands["modules"].
376+
commands["shutdown"], ["LINE-CARD0"], obj=db)
372377
print(result.exit_code)
373378
print(result.output)
374379
assert result.exit_code == 0
375380

376-
result = runner.invoke(show.cli.commands["chassis"].commands["modules"].commands["status"], ["LINE-CARD0"], obj=db)
381+
result = runner.invoke(show.cli.commands["chassis"].commands["modules"].
382+
commands["status"], ["LINE-CARD0"], obj=db)
377383
print(result.exit_code)
378384
print(result.output)
379385
result_lines = result.output.strip('\n').split('\n')
380386
assert result.exit_code == 0
381387
header_lines = 2
382388
result_out = " ".join((result_lines[header_lines]).split())
383389
assert result_out.strip('\n') == show_linecard0_shutdown_output.strip('\n')
384-
#db.cfgdb.set_entry("CHASSIS_MODULE", "LINE-CARD0", { "admin_status" : "down" })
385-
#db.get_data("CHASSIS_MODULE", "LINE-CARD0")
390+
# db.cfgdb.set_entry("CHASSIS_MODULE", "LINE-CARD0", { "admin_status" : "down" })
391+
# db.get_data("CHASSIS_MODULE", "LINE-CARD0")
386392

387393
def test_config_shutdown_module_fabric(self):
388394
with mock.patch("utilities_common.cli.run_command",
@@ -430,12 +436,14 @@ def test_config_startup_module(self):
430436
with mock.patch("config.chassis_modules.StateDBHelper", new=MockStateDBHelper):
431437
runner = CliRunner()
432438
db = Db()
433-
result = runner.invoke(config.config.commands["chassis"].commands["modules"].commands["startup"], ["LINE-CARD0"], obj=db)
439+
result = runner.invoke(config.config.commands["chassis"].commands["modules"].
440+
commands["startup"], ["LINE-CARD0"], obj=db)
434441
print(result.exit_code)
435442
print(result.output)
436443
assert result.exit_code == 0
437444

438-
result = runner.invoke(show.cli.commands["chassis"].commands["modules"].commands["status"], ["LINE-CARD0"], obj=db)
445+
result = runner.invoke(show.cli.commands["chassis"].commands["modules"].
446+
commands["status"], ["LINE-CARD0"], obj=db)
439447
print(result.exit_code)
440448
print(result.output)
441449
result_lines = result.output.strip('\n').split('\n')

0 commit comments

Comments
 (0)