Skip to content

Commit 157074f

Browse files
committed
Decouple netmiko save tests from config tests
1 parent 34303a6 commit 157074f

File tree

2 files changed

+74
-86
lines changed

2 files changed

+74
-86
lines changed

tests/test_netmiko_config.py

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,4 @@
11
#!/usr/bin/env python
2-
"""
3-
This module runs tests against Cisco IOS devices.
4-
5-
setup_module: setup variables for later use.
6-
7-
test_ssh_connect: verify ssh connectivity
8-
test_enable_mode: verify enter enable mode
9-
test_config_mode: verify enter config mode
10-
test_exit_config_mode: verify exit config mode
11-
test_command_set: verify sending a set of config commands
12-
test_commands_from_file: verify sending a set of config commands from a file
13-
test_save_base: verify save config with default values
14-
test_save_confirm: verify save config with confirm
15-
test_save_response: verify save config with response
16-
test_save_cmd: verify save config with cmd
17-
test_save_confirm_response: verify save config with confirm and confirm response
18-
test_save_all: verify save config with all options
19-
test_disconnect: cleanly disconnect the SSH session
20-
21-
"""
22-
232
from __future__ import print_function
243
from __future__ import unicode_literals
254

@@ -106,74 +85,9 @@ def test_commands_from_file(net_connect, commands, expected_responses):
10685
else:
10786
print("Skipping test (no file specified)...",)
10887

109-
def test_save_base(net_connect, commands, expected_responses):
110-
'''
111-
Test save config with no options.
112-
'''
113-
save_verify = expected_responses['save_config']
114-
115-
cmd_response = net_connect.save_config()
116-
assert save_verify in cmd_response
117-
118-
def test_save_confirm(net_connect, commands, expected_responses):
119-
'''
120-
Test save config with the confirm parameter.
121-
'''
122-
confirm = commands['save_config_confirm']
123-
save_verify = expected_responses['save_config']
124-
125-
cmd_response = net_connect.save_config(confirm)
126-
assert save_verify in cmd_response
127-
128-
def test_save_response(net_connect, commands, expected_responses):
129-
'''
130-
Test save config with the confirm response parameter.
131-
'''
132-
confirm_response = commands['save_config_response']
133-
save_verify = expected_responses['save_config']
134-
135-
cmd_response = net_connect.save_config(confirm_response=confirm_response)
136-
assert save_verify in cmd_response
137-
138-
def test_save_cmd(net_connect, commands, expected_responses):
139-
'''
140-
Test save config with cmd parameter.
141-
'''
142-
cmd = commands['save_config_cmd']
143-
save_verify = expected_responses['save_config']
144-
145-
cmd_response = net_connect.save_config(cmd=cmd)
146-
assert save_verify in cmd_response
147-
148-
def test_save_confirm_response(net_connect, commands, expected_responses):
149-
'''
150-
Test save config with confirm and confirm response parameters
151-
'''
152-
confirm = commands['save_config_confirm']
153-
confirm_response = commands['save_config_response']
154-
save_verify = expected_responses['save_config']
155-
156-
cmd_response = net_connect.save_config(confirm=confirm,
157-
confirm_response=confirm_response)
158-
assert save_verify in cmd_response
159-
160-
def test_save_all(net_connect, commands, expected_responses):
161-
'''
162-
Test the save config method with all additional parameters.
163-
'''
164-
cmd = commands['save_config_cmd']
165-
confirm = commands['save_config_confirm']
166-
confirm_response = commands['save_config_response']
167-
save_verify = expected_responses['save_config']
168-
169-
cmd_response = net_connect.save_config(cmd=cmd, confirm=confirm,
170-
confirm_response=confirm_response)
171-
assert save_verify in cmd_response
17288

17389
def test_disconnect(net_connect, commands, expected_responses):
17490
'''
17591
Terminate the SSH session
17692
'''
17793
net_connect.disconnect()
178-
179-

tests/test_netmiko_save.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env python
2+
from __future__ import print_function
3+
from __future__ import unicode_literals
4+
5+
6+
def test_save_base(net_connect, commands, expected_responses):
7+
'''
8+
Test save config with no options.
9+
'''
10+
save_verify = expected_responses['save_config']
11+
12+
cmd_response = net_connect.save_config()
13+
assert save_verify in cmd_response
14+
15+
def test_save_confirm(net_connect, commands, expected_responses):
16+
'''
17+
Test save config with the confirm parameter.
18+
'''
19+
confirm = commands['save_config_confirm']
20+
save_verify = expected_responses['save_config']
21+
22+
cmd_response = net_connect.save_config(confirm)
23+
assert save_verify in cmd_response
24+
25+
def test_save_response(net_connect, commands, expected_responses):
26+
'''
27+
Test save config with the confirm response parameter.
28+
'''
29+
confirm_response = commands['save_config_response']
30+
save_verify = expected_responses['save_config']
31+
32+
cmd_response = net_connect.save_config(confirm_response=confirm_response)
33+
assert save_verify in cmd_response
34+
35+
def test_save_cmd(net_connect, commands, expected_responses):
36+
'''
37+
Test save config with cmd parameter.
38+
'''
39+
cmd = commands['save_config_cmd']
40+
save_verify = expected_responses['save_config']
41+
42+
cmd_response = net_connect.save_config(cmd=cmd)
43+
assert save_verify in cmd_response
44+
45+
def test_save_confirm_response(net_connect, commands, expected_responses):
46+
'''
47+
Test save config with confirm and confirm response parameters
48+
'''
49+
confirm = commands['save_config_confirm']
50+
confirm_response = commands['save_config_response']
51+
save_verify = expected_responses['save_config']
52+
53+
cmd_response = net_connect.save_config(confirm=confirm,
54+
confirm_response=confirm_response)
55+
assert save_verify in cmd_response
56+
57+
def test_save_all(net_connect, commands, expected_responses):
58+
'''
59+
Test the save config method with all additional parameters.
60+
'''
61+
cmd = commands['save_config_cmd']
62+
confirm = commands['save_config_confirm']
63+
confirm_response = commands['save_config_response']
64+
save_verify = expected_responses['save_config']
65+
66+
cmd_response = net_connect.save_config(cmd=cmd, confirm=confirm,
67+
confirm_response=confirm_response)
68+
assert save_verify in cmd_response
69+
70+
def test_disconnect(net_connect, commands, expected_responses):
71+
'''
72+
Terminate the SSH session
73+
'''
74+
net_connect.disconnect()

0 commit comments

Comments
 (0)