|
16 | 16 | | | 12.0.0.2 |
|
17 | 17 | | | 12.0.0.3 |
|
18 | 18 | +------------------+-----------------------+
|
| 19 | +| PortChannel0001 | 11.0.0.1 | |
| 20 | +| | 11.0.0.2 | |
| 21 | +| | 11.0.0.3 | |
| 22 | ++------------------+-----------------------+ |
19 | 23 | | Vlan1000 | 192.0.0.1 |
|
20 | 24 | | | 192.0.0.2 |
|
21 | 25 | | | 192.0.0.3 |
|
|
48 | 52 | Restarting DHCP relay service...
|
49 | 53 | """
|
50 | 54 |
|
| 55 | +config_portchannel_add_dhcp_relay_output="""\ |
| 56 | +Added DHCP relay address 11.0.0.4 to PortChannel0001 |
| 57 | +Restarting DHCP relay service... |
| 58 | +""" |
| 59 | + |
| 60 | +config_portchannel_rem_dhcp_relay_output="""\ |
| 61 | +Removed DHCP relay address 11.0.0.3 from PortChannel0001 |
| 62 | +Restarting DHCP relay service... |
| 63 | +""" |
| 64 | + |
51 | 65 | class TestDhcpRelay(object):
|
52 | 66 | @classmethod
|
53 | 67 | def setup_class(cls):
|
@@ -114,6 +128,35 @@ def test_config_add_delete_dhcp_server_on_vlan_interface(self):
|
114 | 128 | assert result.output == config_vlan_rem_dhcp_relay_output
|
115 | 129 | assert mock_run_command.call_count == 3
|
116 | 130 |
|
| 131 | + def test_config_add_delete_dhcp_server_on_portchannel_interface(self): |
| 132 | + runner = CliRunner() |
| 133 | + db = Db() |
| 134 | + obj = {'db':db.cfgdb} |
| 135 | + |
| 136 | + with mock.patch("utilities_common.cli.run_command") as mock_run_command: |
| 137 | + # add a same dhcp relay server address to PortChannel0001 |
| 138 | + result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["dhcp-relay"].commands["add"], ["PortChannel0001", "11.0.0.3"], obj=obj) |
| 139 | + print(result.exit_code) |
| 140 | + print(result.output) |
| 141 | + assert result.exit_code != 0 |
| 142 | + assert "Error: IP address 11.0.0.3 is already configured" in result.output |
| 143 | + |
| 144 | + # remove dhcp relay server address from PortChannel0001 |
| 145 | + result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["dhcp-relay"].commands["remove"], ["PortChannel0001", "11.0.0.3"], obj=obj) |
| 146 | + print(result.exit_code) |
| 147 | + print(result.output) |
| 148 | + assert result.exit_code == 0 |
| 149 | + assert result.output == config_portchannel_rem_dhcp_relay_output |
| 150 | + assert mock_run_command.call_count == 3 |
| 151 | + |
| 152 | + # add a new dhcp relay server address to PortChannel0001 |
| 153 | + result = runner.invoke(config.config.commands["interface"].commands["ip"].commands["dhcp-relay"].commands["add"], ["PortChannel0001", "11.0.0.4"], obj=obj) |
| 154 | + print(result.exit_code) |
| 155 | + print(result.output) |
| 156 | + assert result.exit_code == 0 |
| 157 | + assert result.output == config_portchannel_add_dhcp_relay_output |
| 158 | + assert mock_run_command.call_count == 6 |
| 159 | + |
117 | 160 | @classmethod
|
118 | 161 | def teardown_class(cls):
|
119 | 162 | os.environ['UTILITIES_UNIT_TESTING'] = "0"
|
|
0 commit comments