Skip to content

Commit ccea754

Browse files
committed
included tests
1 parent 1c7fc91 commit ccea754

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from st2tests.base import BaseActionTestCase
2+
from netmiko_automation.send_command import main
3+
4+
import mock
5+
6+
__all__ = ["TestNetmikoAutomation"]
7+
8+
9+
class TestNetmikoAutomation(BaseActionTestCase):
10+
action_cls = main
11+
12+
@mock.patch("netmiko_automation.send_command.connect")
13+
def test_main(self, mock_connect):
14+
mock_connection = mock.MagicMock()
15+
mock_connection.send_command.return_value = "Output of the command"
16+
mock_connect.return_value = mock_connection
17+
18+
action = self.get_action_instance()
19+
result = action.run(
20+
hostname="example.com", device_type="cisco_ios", port="22", command="show version")
21+
22+
self.assertEqual(result, "Output of the command")
23+
mock_connect.assert_called_once_with(
24+
"example.com", "user", "password", device_type="cisco_ios", port="22")
25+
mock_connection.send_command.assert_called_once_with("show version")
26+
27+
28+
if __name__ == '__main__':
29+
unittest.main()

0 commit comments

Comments
 (0)