forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sonic-py-common] Relocate some functions from sonic-utilities (sonic…
…-net#5269) * Relocate interface related common functions to py-common * Add unit tests for interface API's.
- Loading branch information
1 parent
f973d90
commit ca3e71d
Showing
3 changed files
with
95 additions
and
0 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,41 @@ | ||
import os | ||
import sys | ||
|
||
from sonic_py_common import interface | ||
|
||
class TestInterface(object): | ||
@classmethod | ||
def setup_class(cls): | ||
print("SETUP") | ||
|
||
def test_get_interface_table_name(self): | ||
result = interface.get_interface_table_name("Ethernet0") | ||
assert result == "INTERFACE" | ||
result = interface.get_interface_table_name("Ethernet0.100") | ||
assert result == "VLAN_SUB_INTERFACE" | ||
result = interface.get_interface_table_name("PortChannel0") | ||
assert result == "PORTCHANNEL_INTERFACE" | ||
result = interface.get_interface_table_name("PortChannel0.100") | ||
assert result == "VLAN_SUB_INTERFACE" | ||
result = interface.get_interface_table_name("Vlan100") | ||
assert result == "VLAN_INTERFACE" | ||
result = interface.get_interface_table_name("Loopback0") | ||
assert result == "LOOPBACK_INTERFACE" | ||
|
||
def test_get_port_table_name(self): | ||
result = interface.get_port_table_name("Ethernet0") | ||
assert result == "PORT" | ||
result = interface.get_port_table_name("Ethernet0.100") | ||
assert result == "VLAN_SUB_INTERFACE" | ||
result = interface.get_port_table_name("PortChannel0") | ||
assert result == "PORTCHANNEL" | ||
result = interface.get_port_table_name("PortChannel0.100") | ||
assert result == "VLAN_SUB_INTERFACE" | ||
result = interface.get_port_table_name("Vlan100") | ||
assert result == "VLAN_INTERFACE" | ||
result = interface.get_port_table_name("Loopback0") | ||
assert result == "LOOPBACK_INTERFACE" | ||
|
||
@classmethod | ||
def teardown_class(cls): | ||
print("TEARDOWN") |