@@ -64,6 +64,12 @@ def test_console_add_success(self):
64
64
print (sys .stderr , result .output )
65
65
assert result .exit_code == 0
66
66
67
+ # add a console setting with device name option
68
+ result = runner .invoke (config .config .commands ["console" ].commands ["add" ], ["2" , '--baud' , "9600" , "--devicename" , "switch1" ], obj = db )
69
+ print (result .exit_code )
70
+ print (sys .stderr , result .output )
71
+ assert result .exit_code == 0
72
+
67
73
def test_console_del_non_exists (self ):
68
74
runner = CliRunner ()
69
75
db = Db ()
@@ -85,3 +91,126 @@ def test_console_del_success(self):
85
91
print (result .exit_code )
86
92
print (sys .stderr , result .output )
87
93
assert result .exit_code == 0
94
+
95
+ def test_update_console_remote_device_name_non_exists (self ):
96
+ runner = CliRunner ()
97
+ db = Db ()
98
+
99
+ # trying to update a console line remote device configuration which is not exists
100
+ result = runner .invoke (config .config .commands ["console" ].commands ["remote_device" ], ["1" , "switch1" ], obj = db )
101
+ print (result .exit_code )
102
+ print (sys .stderr , result .output )
103
+ assert result .exit_code != 0
104
+ assert "Trying to update console port setting, which is not present." in result .output
105
+
106
+ def test_update_console_remote_device_name_conflict (self ):
107
+ runner = CliRunner ()
108
+ db = Db ()
109
+ db .cfgdb .set_entry ("CONSOLE_PORT" , 1 , { "baud" : "9600" })
110
+ db .cfgdb .set_entry ("CONSOLE_PORT" , 2 , { "baud" : "9600" , "remote_device" : "switch1" })
111
+
112
+ # trying to update a console line remote device configuration which is not exists
113
+ result = runner .invoke (config .config .commands ["console" ].commands ["remote_device" ], ["1" , "switch1" ], obj = db )
114
+ print (result .exit_code )
115
+ print (sys .stderr , result .output )
116
+ assert result .exit_code != 0
117
+ assert "Please enter a valid device name or remove the existing one" in result .output
118
+
119
+ def test_update_console_remote_device_name_existing_and_same (self ):
120
+ runner = CliRunner ()
121
+ db = Db ()
122
+ db .cfgdb .set_entry ("CONSOLE_PORT" , 2 , { "remote_device" : "switch1" })
123
+
124
+ # trying to update a console line remote device configuration which is existing and same with user provided value
125
+ result = runner .invoke (config .config .commands ["console" ].commands ["remote_device" ], ["2" , "switch1" ], obj = db )
126
+ print (result .exit_code )
127
+ print (sys .stderr , result .output )
128
+ assert result .exit_code == 0
129
+
130
+ def test_update_console_remote_device_name_reset (self ):
131
+ runner = CliRunner ()
132
+ db = Db ()
133
+ db .cfgdb .set_entry ("CONSOLE_PORT" , 2 , { "remote_device" : "switch1" })
134
+
135
+ # trying to reset a console line remote device configuration which is not exists
136
+ result = runner .invoke (config .config .commands ["console" ].commands ["remote_device" ], ["2" ], obj = db )
137
+ print (result .exit_code )
138
+ print (sys .stderr , result .output )
139
+ assert result .exit_code == 0
140
+
141
+ def test_update_console_remote_device_name_success (self ):
142
+ runner = CliRunner ()
143
+ db = Db ()
144
+ db .cfgdb .set_entry ("CONSOLE_PORT" , "1" , { "baud_rate" : "9600" })
145
+
146
+ # trying to set a console line remote device configuration
147
+ result = runner .invoke (config .config .commands ["console" ].commands ["remote_device" ], ["1" , "switch1" ], obj = db )
148
+ print (result .exit_code )
149
+ print (sys .stderr , result .output )
150
+ assert result .exit_code == 0
151
+
152
+ def test_update_console_baud_no_change (self ):
153
+ runner = CliRunner ()
154
+ db = Db ()
155
+ db .cfgdb .set_entry ("CONSOLE_PORT" , "1" , { "baud_rate" : "9600" })
156
+
157
+ # trying to set a console line baud which is same with existing one
158
+ result = runner .invoke (config .config .commands ["console" ].commands ["baud" ], ["1" , "9600" ], obj = db )
159
+ print (result .exit_code )
160
+ print (sys .stderr , result .output )
161
+ assert result .exit_code == 0
162
+
163
+ def test_update_console_baud_non_exists (self ):
164
+ runner = CliRunner ()
165
+ db = Db ()
166
+
167
+ # trying to set a console line baud which is not exists
168
+ result = runner .invoke (config .config .commands ["console" ].commands ["baud" ], ["1" , "9600" ], obj = db )
169
+ print (result .exit_code )
170
+ print (sys .stderr , result .output )
171
+ assert result .exit_code != 0
172
+ assert "Trying to update console port setting, which is not present." in result .output
173
+
174
+ def test_update_console_baud_success (self ):
175
+ runner = CliRunner ()
176
+ db = Db ()
177
+ db .cfgdb .set_entry ("CONSOLE_PORT" , "1" , { "baud_rate" : "9600" })
178
+
179
+ # trying to set a console line baud
180
+ result = runner .invoke (config .config .commands ["console" ].commands ["baud" ], ["1" , "115200" ], obj = db )
181
+ print (result .exit_code )
182
+ print (sys .stderr , result .output )
183
+ assert result .exit_code == 0
184
+
185
+ def test_update_console_flow_control_no_change (self ):
186
+ runner = CliRunner ()
187
+ db = Db ()
188
+ db .cfgdb .set_entry ("CONSOLE_PORT" , "1" , { "baud_rate" : "9600" , "flow_control" : "0" })
189
+
190
+ # trying to set a console line flow control option which is same with existing one
191
+ result = runner .invoke (config .config .commands ["console" ].commands ["flow_control" ], ["disable" , "1" ], obj = db )
192
+ print (result .exit_code )
193
+ print (sys .stderr , result .output )
194
+ assert result .exit_code == 0
195
+
196
+ def test_update_console_flow_control_non_exists (self ):
197
+ runner = CliRunner ()
198
+ db = Db ()
199
+
200
+ # trying to set a console line flow control option which is not exists
201
+ result = runner .invoke (config .config .commands ["console" ].commands ["flow_control" ], ["enable" , "1" ], obj = db )
202
+ print (result .exit_code )
203
+ print (sys .stderr , result .output )
204
+ assert result .exit_code != 0
205
+ assert "Trying to update console port setting, which is not present." in result .output
206
+
207
+ def test_update_console_flow_control_success (self ):
208
+ runner = CliRunner ()
209
+ db = Db ()
210
+ db .cfgdb .set_entry ("CONSOLE_PORT" , "1" , { "baud_rate" : "9600" , "flow_control" : "0" })
211
+
212
+ # trying to set a console line flow control option
213
+ result = runner .invoke (config .config .commands ["console" ].commands ["flow_control" ], ["enable" , "1" ], obj = db )
214
+ print (result .exit_code )
215
+ print (sys .stderr , result .output )
216
+ assert result .exit_code == 0
0 commit comments