Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stveit committed Nov 3, 2023
1 parent 6507a2d commit 3e1c44c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/unittests/portadmin/portadmin_poe_cisco_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,20 @@ def test_use_interfaces_from_db_if_empty_interfaces_arg(self, handler_cisco):
handler_cisco.netbox.interfaces = [interface]
state = handler_cisco.get_poe_states()
assert interface.ifname in state


class TestGetPoeIndexesForInterface:
def test_returns_correct_values(self, handler_cisco):
poegroup_mock = Mock(index=1)
poeport_mock = Mock(poegroup=poegroup_mock, index=2)
handler_cisco._get_poeport = Mock(return_value=poeport_mock)
interface = Mock(ifname="interface")
unit_number, if_number = handler_cisco._get_poe_indexes_for_interface(interface)
assert unit_number == poegroup_mock.index
assert if_number == poeport_mock.index

def test_raises_exception_if_no_poeport_exists(self, handler_cisco):
handler_cisco._get_poeport = Mock(side_effect=POEIndexNotFoundError("Fail"))
interface = Mock(ifname="interface")
with pytest.raises(POEIndexNotFoundError):
handler_cisco._get_poe_indexes_for_interface(interface)

0 comments on commit 3e1c44c

Please sign in to comment.