|
| 1 | +# Copyright 2022 EscherCloud. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | +# not use this file except in compliance with the License. You may obtain |
| 5 | +# a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | +# License for the specific language governing permissions and limitations |
| 13 | +# under the License. |
| 14 | + |
| 15 | +from unittest import mock |
| 16 | + |
| 17 | +from networking_generic_switch.devices.netmiko_devices import pluribus |
| 18 | +from networking_generic_switch.tests.unit.netmiko import test_netmiko_base |
| 19 | + |
| 20 | + |
| 21 | +class TestNetmikoPluribus(test_netmiko_base.NetmikoSwitchTestBase): |
| 22 | + |
| 23 | + def _make_switch_device(self): |
| 24 | + device_cfg = {'device_type': 'netmiko_pluribus'} |
| 25 | + return pluribus.Pluribus(device_cfg) |
| 26 | + |
| 27 | + @mock.patch('networking_generic_switch.devices.netmiko_devices.' |
| 28 | + 'NetmikoSwitch.send_commands_to_device') |
| 29 | + def test_add_network(self, m_exec): |
| 30 | + self.switch.add_network(33, '0ae071f5-5be9-43e4-80ea-e41fefe85b21') |
| 31 | + m_exec.assert_called_with( |
| 32 | + ['vlan-create id 33 scope fabric ports none description\ |
| 33 | + 0ae071f55be943e480eae41fefe85b21 auto-vxlan']) |
| 34 | + |
| 35 | + @mock.patch('networking_generic_switch.devices.netmiko_devices.' |
| 36 | + 'NetmikoSwitch.send_commands_to_device') |
| 37 | + def test_del_network(self, mock_exec): |
| 38 | + self.switch.del_network(33, '0ae071f5-5be9-43e4-80ea-e41fefe85b21') |
| 39 | + mock_exec.assert_called_with(['vlan-delete id 33']) |
| 40 | + |
| 41 | + @mock.patch('networking_generic_switch.devices.netmiko_devices.' |
| 42 | + 'NetmikoSwitch.send_commands_to_device') |
| 43 | + def test_plug_port_to_network(self, mock_exec): |
| 44 | + self.switch.plug_port_to_network(3333, 33) |
| 45 | + mock_exec.assert_called_with( |
| 46 | + ['vlan-port-remove vlan-range all ports 3333', |
| 47 | + 'port-vlan-add port 3333 untagged-vlan 33', ]) |
| 48 | + |
| 49 | + @mock.patch('networking_generic_switch.devices.netmiko_devices.' |
| 50 | + 'NetmikoSwitch.send_commands_to_device') |
| 51 | + def test_delete_port(self, mock_exec): |
| 52 | + self.switch.delete_port(3333, 33) |
| 53 | + mock_exec.assert_called_with( |
| 54 | + ['vlan-port-remove vlan-range all ports 3333']) |
0 commit comments