Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: vaibhav-dahiya <vdahiya@microsoft.com>
  • Loading branch information
vdahiya12 committed Oct 21, 2022
1 parent cc96144 commit 81cf7ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
11 changes: 2 additions & 9 deletions sonic-ycabled/tests/test_ycable.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ def test_ycable_info_helper_class_run(self, mocked_sleep):
with patch('ycable.ycable.platform_sfputil') as patched_util:
patched_util.logical.return_value = ['Ethernet0', 'Ethernet4']
patched_util.get_asic_id_for_logical_port.return_value = 0
stopping_event = MagicMock()
sfp_error_event = MagicMock()
Y_cable_state_task = YcableStateUpdateTask(sfp_error_event, y_cable_presence)
Y_cable_state_task.task_process = MagicMock()
Y_cable_state_task.task_stopping_event = MagicMock()
stopping_event = MagicMock()
sfp_error_event = MagicMock()
y_cable_presence = [True]
Y_cable_state_task.start()
Y_cable_state_task.join()
Expand All @@ -71,9 +71,6 @@ def test_ycable_helper_class_run_loop(self):
Y_cable_task.task_thread = MagicMock()
Y_cable_task.task_thread.start = MagicMock()
Y_cable_task.task_thread.join = MagicMock()
Y_cable_task.task_cli_thead = MagicMock()
Y_cable_task.task_cli_thead.start = MagicMock()
Y_cable_task.task_cli_thead.join = MagicMock()
#Y_cable_task.task_stopping_event.return_value.is_set.return_value = False
swsscommon.SubscriberStateTable.return_value.pop.return_value = (True, True, {"read_side": "2"})
Y_cable_task.task_worker()
Expand All @@ -88,12 +85,8 @@ def test_ycable_helper_class_run(self):
Y_cable_task.task_thread = MagicMock()
Y_cable_task.task_thread.start = MagicMock()
Y_cable_task.task_thread.join = MagicMock()
Y_cable_task.task_cli_thead = MagicMock()
Y_cable_task.task_cli_thead.start = MagicMock()
Y_cable_task.task_cli_thead.join = MagicMock()
Y_cable_task.task_stopping_event.return_value.is_set.return_value = True
Y_cable_task.task_worker()
Y_cable_task.task_cli_worker()
Y_cable_task.start()
Y_cable_task.join()

Expand Down
5 changes: 4 additions & 1 deletion sonic-ycabled/ycable/ycable_utilities/y_cable_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,7 @@ def change_ports_status_for_y_cable_change_event(port_dict, y_cable_presence, st

def delete_ports_status_for_y_cable(y_cable_tbl, static_tbl, mux_tbl, port_tbl, grpc_config):

state_db = {}
config_db, state_db
y_cable_tbl_keys = {}
static_tbl, mux_tbl = {}, {}
grpc_config = {}
Expand All @@ -1499,6 +1499,7 @@ def delete_ports_status_for_y_cable(y_cable_tbl, static_tbl, mux_tbl, port_tbl,
for namespace in namespaces:
asic_id = multi_asic.get_asic_index_from_namespace(namespace)
state_db[asic_id] = daemon_base.db_connect("STATE_DB", namespace)
config_db[asic_id] = daemon_base.db_connect("CONFIG_DB", namespace)
y_cable_tbl_keys[asic_id] = y_cable_tbl[asic_id].getKeys()
static_tbl[asic_id] = swsscommon.Table(
state_db[asic_id], MUX_CABLE_STATIC_INFO_TABLE)
Expand Down Expand Up @@ -3442,6 +3443,8 @@ def handle_ycable_enable_disable_tel_notification(fvp_m, key):
class YCableTableUpdateTask(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)

self.exc = None
self.task_thread = None
self.task_cli_thread = None
self.task_download_firmware_thread = {}
Expand Down

0 comments on commit 81cf7ca

Please sign in to comment.