Skip to content

Commit

Permalink
Fix CiscoRange(result_type=foo) tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mpenning committed Oct 22, 2023
1 parent 79ea1e9 commit d138a5c
Showing 1 changed file with 35 additions and 63 deletions.
98 changes: 35 additions & 63 deletions tests/test_Ccp_Util.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,135 +713,110 @@ def test_CiscoInterface_07():

def test_CiscoRange_01():
"""Basic vlan range test"""
result_correct = {"1", "2", "3"}
result_correct = {1, 2, 3}
uut_str = "1-3"
assert isinstance(uut_str, str)
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct
assert CiscoRange(uut_str).iterate_attribute == "port"
assert CiscoRange(uut_str, result_type=int).as_set(result_type=int) == result_correct


def test_CiscoRange_02():
"""Basic vlan range test"""
result_correct = {"1", "3"}
result_correct = {1, 3}
uut_str = "1,3"
assert isinstance(uut_str, str)
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct
assert CiscoRange(uut_str).iterate_attribute == "port"
assert CiscoRange(uut_str, result_type=int).as_set(result_type=int) == result_correct


def test_CiscoRange_03():
"""Basic vlan range test"""
result_correct = {
"1",
"2",
"3",
"4",
"5",
}
result_correct = {1, 2, 3, 4, 5}
uut_str = "1,2-4,5"
assert isinstance(uut_str, str)
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct
assert CiscoRange(uut_str).iterate_attribute == "port"
assert CiscoRange(uut_str, result_type=int).as_set(result_type=int) == result_correct


def test_CiscoRange_04():
"""Basic vlan range test"""
result_correct = {"1", "2", "3", "4", "5"}
result_correct = {1, 2, 3, 4, 5}
uut_str = "1-3,4,5"
assert isinstance(uut_str, str)
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct
assert CiscoRange(uut_str).iterate_attribute == "port"
assert CiscoRange(uut_str, result_type=int).as_set(result_type=int) == result_correct


def test_CiscoRange_05():
"""Basic vlan range test"""
result_correct = {"1", "2", "3", "4", "5"}
result_correct = {1, 2, 3, 4, 5}
uut_str = "1,2,3-5"
assert isinstance(uut_str, str)
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct
assert CiscoRange(uut_str).iterate_attribute == "port"
assert CiscoRange(uut_str, result_type=int).as_set(result_type=int) == result_correct


def test_CiscoRange_06():
"""Basic slot range test"""
result_correct = {"1/1", "1/2", "1/3", "1/4", "1/5"}
uut_str = "1/1-3,4,5"
assert isinstance(uut_str, str)
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct
# the CiscoRange() result_type None is a CiscoInterface() type with a
# port attribute...
assert CiscoRange(uut_str, result_type=None).as_set(result_type=str) == result_correct
assert CiscoRange(uut_str).iterate_attribute == "port"


def test_CiscoRange_07():
"""Basic slot range test"""
result_correct = {"1/1", "1/2", "1/3", "1/4", "1/5"}
uut_str = "1/1,2-4,5"
assert isinstance(uut_str, str)
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct


def test_CiscoRange_08():
"""Basic slot range test"""
result_correct = {"1/1", "1/2", "1/3", "1/4", "1/5"}
uut_str = "1/1,2,3-5"
assert isinstance(uut_str, str)
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct


def test_CiscoRange_09():
"""Basic slot range test"""
result_correct = {"2/1/1", "2/1/2", "2/1/3", "2/1/4", "2/1/5"}
uut_str = "2/1/1-3,4,5"
assert isinstance(uut_str, str)
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct


def test_CiscoRange_10():
"""Basic slot range test"""
result_correct = {"2/1/1", "2/1/2", "2/1/3", "2/1/4", "2/1/5"}
uut_str = "2/1/1,2-4,5"
assert isinstance(uut_str, str)
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct


def test_CiscoRange_11():
"""Basic slot range test"""
result_correct = {"2/1/1", "2/1/2", "2/1/3", "2/1/4", "2/1/5"}
uut_str = "2/1/1,2,3-5"
assert isinstance(uut_str, str)
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct


if False:
def test_CiscoRange_12():
"""Basic interface slot range test"""
result_correct = {"2/1/1", "2/1/2", "2/1/3", "2/1/4", "2/1/5"}
uut_str = "interface Eth2/1/1-3,4,5"
assert isinstance(uut_str, str)
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct
def test_CiscoRange_12():
"""Basic interface slot range test"""
result_correct = {"2/1/1", "2/1/2", "2/1/3", "2/1/4", "2/1/5"}
uut_str = "interface Eth2/1/1-3,4,5"
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct


def test_CiscoRange_13():
"""Basic interface slot range test"""
result_correct = {"2/1/1", "2/1/2", "2/1/3", "2/1/4", "2/1/5"}
uut_str = "interface Eth2/1/1,2-4,5"
assert isinstance(uut_str, str)
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct
def test_CiscoRange_13():
"""Basic interface slot range test"""
result_correct = {"2/1/1", "2/1/2", "2/1/3", "2/1/4", "2/1/5"}
uut_str = "interface Eth2/1/1,2-4,5"
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct


def test_CiscoRange_14():
"""Basic interface slot range test"""
result_correct = {"2/1/1", "2/1/2", "2/1/3", "2/1/4", "2/1/5"}
uut_str = "interface Eth2/1/1,2,3-5"
assert isinstance(uut_str, str)
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct
def test_CiscoRange_14():
"""Basic interface slot range test"""
result_correct = {"2/1/1", "2/1/2", "2/1/3", "2/1/4", "2/1/5"}
uut_str = "interface Eth2/1/1,2,3-5"
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct


def test_CiscoRange_15():
"""Basic interface slot range test"""
result_correct = {"2/1/1", "2/1/2", "2/1/3", "2/1/4", "2/1/5"}
uut_str = "interface Eth 2/1/1,2,3-5"
assert isinstance(uut_str, str)
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct
def test_CiscoRange_15():
"""Basic interface slot range test"""
result_correct = {"2/1/1", "2/1/2", "2/1/3", "2/1/4", "2/1/5"}
uut_str = "interface Eth 2/1/1,2,3-5"
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct


def test_CiscoRange_18():
Expand All @@ -852,7 +827,6 @@ def test_CiscoRange_18():
"Eth1/20"
}
uut_str = "Eth1/1,Eth1/12-20,Eth1/16,Eth1/10"
assert isinstance(uut_str, str)
assert CiscoRange(uut_str).as_set(result_type=str) == result_correct


Expand Down Expand Up @@ -885,14 +859,12 @@ def test_CiscoRange_20():
def test_CiscoRange_compressed_str_01():
"""compressed_str test with a very basic set of vlan numbers"""
uut_str = "1,2,911"
assert CiscoRange(uut_str, result_type=str).as_compressed_str() == "1,2,911"
assert "2" in CiscoRange(uut_str).as_compressed_str()
assert "911" in CiscoRange(uut_str).as_compressed_str()
assert CiscoRange(uut_str, result_type=int).as_compressed_str() == "1,2,911"

def test_CiscoRange_compressed_str_02():
"""compressed_str test with vlan number ranges"""
uut_str = "1,2, 3, 6, 7, 8 , 9, 911"
assert CiscoRange(uut_str, result_type=str).as_compressed_str() == "1-3,6-9,911"
assert CiscoRange(uut_str, result_type=int).as_compressed_str() == "1-3,6-9,911"


def test_CiscoRange_contains_01():
Expand Down

0 comments on commit d138a5c

Please sign in to comment.