-
Notifications
You must be signed in to change notification settings - Fork 650
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a04176d
commit 56f74cd
Showing
4 changed files
with
211 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
import os | ||
|
||
from click.testing import CliRunner | ||
|
||
import config.main as config | ||
import show.main as show | ||
from utilities_common.db import Db | ||
|
||
show_ipv6_link_local_mode_output="""\ | ||
+------------------+----------+ | ||
| Interface Name | Mode | | ||
+==================+==========+ | ||
| Ethernet0 | Disabled | | ||
+------------------+----------+ | ||
| PortChannel0001 | Disabled | | ||
+------------------+----------+ | ||
""" | ||
|
||
class TestIPv6LinkLocal(object): | ||
@classmethod | ||
def setup_class(cls): | ||
os.environ['UTILITIES_UNIT_TESTING'] = "1" | ||
print("SETUP") | ||
|
||
def test_show_ipv6_link_local_mode(self): | ||
runner = CliRunner() | ||
db = Db() | ||
obj = {'db':db.cfgdb} | ||
|
||
# show ipv6 link-local-mode output | ||
result = runner.invoke(show.cli.commands["ipv6"].commands["link-local-mode"], [], obj=obj) | ||
print(result.output) | ||
assert result.output == show_ipv6_link_local_mode_output | ||
|
||
def test_config_enable_disable_ipv6_link_local_on_physical_interface(self): | ||
runner = CliRunner() | ||
db = Db() | ||
obj = {'db':db.cfgdb} | ||
|
||
# Enable ipv6 link local on Ethernet0 | ||
result = runner.invoke(config.config.commands["interface"].commands["ipv6"].commands["enable"].commands["use-link-local-only"], ["Ethernet0"], obj=obj) | ||
print(result.exit_code) | ||
print(result.output) | ||
assert result.exit_code == 0 | ||
assert result.output == '' | ||
|
||
# Disable ipv6 link local on Ethernet0 | ||
result = runner.invoke(config.config.commands["interface"].commands["ipv6"].commands["disable"].commands["use-link-local-only"], ["Ethernet0"], obj=obj) | ||
print(result.exit_code) | ||
print(result.output) | ||
assert result.exit_code == 0 | ||
assert result.output == '' | ||
|
||
def test_config_enable_disable_ipv6_link_local_on_portchannel_interface(self): | ||
runner = CliRunner() | ||
db = Db() | ||
obj = {'db':db.cfgdb} | ||
|
||
# Enable ipv6 link local on PortChannel0001 | ||
result = runner.invoke(config.config.commands["interface"].commands["ipv6"].commands["enable"].commands["use-link-local-only"], ["PortChannel0001"], obj=obj) | ||
print(result.exit_code) | ||
print(result.output) | ||
assert result.exit_code == 0 | ||
assert result.output == '' | ||
|
||
# Disable ipv6 link local on PortChannel0001 | ||
result = runner.invoke(config.config.commands["interface"].commands["ipv6"].commands["disable"].commands["use-link-local-only"], ["PortChannel0001"], obj=obj) | ||
print(result.exit_code) | ||
print(result.output) | ||
assert result.exit_code == 0 | ||
assert result.output == '' | ||
|
||
def test_config_enable_disable_ipv6_link_local_on_invalid_interface(self): | ||
runner = CliRunner() | ||
db = Db() | ||
obj = {'db':db.cfgdb} | ||
|
||
# Enable ipv6 link local on PortChannel1 | ||
result = runner.invoke(config.config.commands["interface"].commands["ipv6"].commands["enable"].commands["use-link-local-only"], ["PortChannel1"], obj=obj) | ||
print(result.exit_code) | ||
print(result.output) | ||
assert result.exit_code != 0 | ||
assert 'Error: Interface name PortChannel1 is invalid. Please enter a valid interface name!!' in result.output | ||
|
||
# Disable ipv6 link local on Ethernet500 | ||
result = runner.invoke(config.config.commands["interface"].commands["ipv6"].commands["disable"].commands["use-link-local-only"], ["Ethernet500"], obj=obj) | ||
print(result.exit_code) | ||
print(result.output) | ||
assert result.exit_code != 0 | ||
assert 'Error: Interface name Ethernet500 is invalid. Please enter a valid interface name!!' in result.output | ||
|
||
def test_config_enable_disable_ipv6_link_local_on_interface_which_is_member_of_vlan(self): | ||
runner = CliRunner() | ||
db = Db() | ||
obj = {'db':db.cfgdb} | ||
|
||
# Enable ipv6 link local on Ethernet16 | ||
result = runner.invoke(config.config.commands["interface"].commands["ipv6"].commands["enable"].commands["use-link-local-only"], ["Ethernet16"], obj=obj) | ||
print(result.exit_code) | ||
print(result.output) | ||
assert result.exit_code != 0 | ||
assert 'Error: Ethernet16 is configured as a member of vlan. Cannot configure the IPv6 link local mode!' in result.output | ||
|
||
# Disable ipv6 link local on Ethernet16 | ||
result = runner.invoke(config.config.commands["interface"].commands["ipv6"].commands["disable"].commands["use-link-local-only"], ["Ethernet16"], obj=obj) | ||
print(result.exit_code) | ||
print(result.output) | ||
assert result.exit_code != 0 | ||
assert 'Error: Ethernet16 is configured as a member of vlan. Cannot configure the IPv6 link local mode!' in result.output | ||
|
||
def test_config_enable_disable_ipv6_link_local_on_interface_which_is_member_of_portchannel(self): | ||
runner = CliRunner() | ||
db = Db() | ||
obj = {'db':db.cfgdb} | ||
|
||
# Enable ipv6 link local on Ethernet32 | ||
result = runner.invoke(config.config.commands["interface"].commands["ipv6"].commands["enable"].commands["use-link-local-only"], ["Ethernet32"], obj=obj) | ||
print(result.exit_code) | ||
print(result.output) | ||
assert result.exit_code != 0 | ||
assert 'Error: Ethernet32 is configured as a member of portchannel. Cannot configure the IPv6 link local mode!' in result.output | ||
|
||
# Disable ipv6 link local on Ethernet32 | ||
result = runner.invoke(config.config.commands["interface"].commands["ipv6"].commands["disable"].commands["use-link-local-only"], ["Ethernet32"], obj=obj) | ||
print(result.exit_code) | ||
print(result.output) | ||
assert result.exit_code != 0 | ||
assert 'Error: Ethernet32 is configured as a member of portchannel. Cannot configure the IPv6 link local mode!' in result.output | ||
|
||
def test_config_enable_disable_ipv6_link_local_on_all_valid_interfaces(self): | ||
runner = CliRunner() | ||
db = Db() | ||
obj = {'db':db.cfgdb} | ||
|
||
# Enable ipv6 link local on all interfaces | ||
result = runner.invoke(config.config.commands["ipv6"].commands["enable"], obj=obj) | ||
print(result.exit_code) | ||
print(result.output) | ||
assert result.exit_code == 0 | ||
assert result.output == '' | ||
|
||
# Disable ipv6 link local on all interfaces | ||
result = runner.invoke(config.config.commands["ipv6"].commands["disable"], obj=obj) | ||
print(result.exit_code) | ||
print(result.output) | ||
assert result.exit_code == 0 | ||
assert result.output == '' | ||
|
||
@classmethod | ||
def teardown_class(cls): | ||
os.environ['UTILITIES_UNIT_TESTING'] = "0" | ||
print("TEARDOWN") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters