File tree Expand file tree Collapse file tree 2 files changed +47
-2
lines changed Expand file tree Collapse file tree 2 files changed +47
-2
lines changed Original file line number Diff line number Diff line change @@ -156,11 +156,11 @@ def feature_autorestart(db, feature_name):
156
156
feature_table = db .cfgdb .get_table ('FEATURE' )
157
157
if feature_name :
158
158
if feature_table and feature_name in feature_table :
159
- body .append ([feature_name , feature_table [feature_name ][ 'auto_restart' ] ])
159
+ body .append ([feature_name , feature_table [ feature_name ]. get ( 'auto_restart' , 'unknown' ) ])
160
160
else :
161
161
click .echo ("Can not find feature {}" .format (feature_name ))
162
162
sys .exit (1 )
163
163
else :
164
164
for name in natsorted (list (feature_table .keys ())):
165
- body .append ([name , feature_table [name ][ 'auto_restart' ] ])
165
+ body .append ([name , feature_table [ name ]. get ( 'auto_restart' , 'unknown' ) ])
166
166
click .echo (tabulate (body , header ))
Original file line number Diff line number Diff line change 130
130
telemetry enabled
131
131
"""
132
132
133
+ show_feature_autorestart_missing_output = """\
134
+ Feature AutoRestart
135
+ ---------- --------------
136
+ bar unknown
137
+ bgp enabled
138
+ database always_enabled
139
+ dhcp_relay enabled
140
+ lldp enabled
141
+ nat enabled
142
+ pmon enabled
143
+ radv enabled
144
+ restapi enabled
145
+ sflow enabled
146
+ snmp enabled
147
+ swss enabled
148
+ syncd enabled
149
+ teamd enabled
150
+ telemetry enabled
151
+ """
152
+
153
+ show_feature_autorestart_bar_missing_output = """\
154
+ Feature AutoRestart
155
+ --------- -------------
156
+ bar unknown
157
+ """
158
+
133
159
show_feature_bgp_autorestart_output = """\
134
160
Feature AutoRestart
135
161
--------- -------------
@@ -277,6 +303,25 @@ def test_show_unknown_autorestart_status(self, get_cmd_module):
277
303
print (result .output )
278
304
assert result .exit_code == 1
279
305
306
+ def test_show_feature_autorestart_missing (self , get_cmd_module ):
307
+ (config , show ) = get_cmd_module
308
+ db = Db ()
309
+ dbconn = db .db
310
+ db .cfgdb .set_entry ("FEATURE" , "bar" , { "state" : "enabled" })
311
+ runner = CliRunner ()
312
+
313
+ result = runner .invoke (show .cli .commands ["feature" ].commands ["autorestart" ], obj = db )
314
+ print (result .exit_code )
315
+ print (result .output )
316
+ assert result .exit_code == 0
317
+ assert result .output == show_feature_autorestart_missing_output
318
+
319
+ result = runner .invoke (show .cli .commands ["feature" ].commands ["autorestart" ], ["bar" ], obj = db )
320
+ print (result .exit_code )
321
+ print (result .output )
322
+ assert result .exit_code == 0
323
+ assert result .output == show_feature_autorestart_bar_missing_output
324
+
280
325
def test_config_bgp_feature_state (self , get_cmd_module ):
281
326
(config , show ) = get_cmd_module
282
327
db = Db ()
You can’t perform that action at this time.
0 commit comments