@@ -136,6 +136,47 @@ def test_moduleupdater_check_phyentity_fields():
136136 assert model == fvs [CHASSIS_MODULE_INFO_MODEL_FIELD ]
137137 assert str (replaceable ) == fvs [CHASSIS_MODULE_INFO_REPLACEABLE_FIELD ]
138138
139+ def test_moduleupdater_check_phyentity_entry_after_fabric_removal ():
140+ chassis = MockChassis ()
141+ index = 0
142+ name = "FABRIC-CARD0"
143+ desc = "Switch Fabric Module"
144+ slot = 10
145+ serial = "FC1000101"
146+ module_type = ModuleBase .MODULE_TYPE_FABRIC
147+ module = MockModule (index , name , desc , module_type , slot , serial )
148+ replaceable = True
149+ presence = True
150+ model = 'N/A'
151+ parent_name = 'chassis 1'
152+
153+ # Set initial state
154+ status = ModuleBase .MODULE_STATUS_ONLINE
155+ module .set_oper_status (status )
156+ module .set_replaceable (replaceable )
157+ module .set_presence (presence )
158+ module .set_model (model )
159+
160+ chassis .module_list .append (module )
161+
162+ module_updater = ModuleUpdater (SYSLOG_IDENTIFIER , chassis , slot ,
163+ module .supervisor_slot )
164+ module_updater .module_db_update ()
165+ fvs = module_updater .phy_entity_table .get (name )
166+ if isinstance (fvs , list ):
167+ fvs = dict (fvs [- 1 ])
168+ assert str (index ) == fvs ['position_in_parent' ]
169+ assert parent_name == fvs ['parent_name' ]
170+ assert serial == fvs [CHASSIS_MODULE_INFO_SERIAL_FIELD ]
171+ assert model == fvs [CHASSIS_MODULE_INFO_MODEL_FIELD ]
172+ assert str (replaceable ) == fvs [CHASSIS_MODULE_INFO_REPLACEABLE_FIELD ]
173+
174+ presence = False
175+ module .set_presence (presence )
176+ module_updater .module_db_update ()
177+ fvs = module_updater .phy_entity_table .get (name )
178+ assert fvs == None
179+
139180def test_smartswitch_moduleupdater_check_valid_fields ():
140181 chassis = MockSmartSwitchChassis ()
141182 index = 0
0 commit comments