Skip to content

Commit

Permalink
Add tests for get enterprise id in NetboxType
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Aug 10, 2023
1 parent e0ef480 commit 3756c1e
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/integration/models/netbox_type_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from nav.enterprise.ids import VENDOR_ID_H3C
from nav.models.manage import NetboxType


class TestNetboxType(object):
def test_get_enterprise_id_returns_correctly_for_sysobjectid_with_leading_period(
self,
):
sysobjectid = ".1.3.6.1.4.1.25506.1.517"
netbox_type = NetboxType(
vendor_id="hp",
name="A5120-48P-EI-2",
description="HP Procurve A5120 V2",
sysobjectid=sysobjectid,
)

assert netbox_type.get_enterprise_id() == VENDOR_ID_H3C

def test_get_enterprise_id_returns_correctly_for_sysobjectid_without_leading_period(
self,
):
sysobjectid = "1.3.6.1.4.1.25506.1.517"
netbox_type = NetboxType(
vendor_id="hp",
name="A5120-48P-EI-2",
description="HP Procurve A5120 V2",
sysobjectid=sysobjectid,
)

assert netbox_type.get_enterprise_id() == VENDOR_ID_H3C

def test_get_enterprise_id_returns_none_for_sysobjectid_of_wrong_format(
self,
):
sysobjectid = "abc"
netbox_type = NetboxType(
vendor_id="hp",
name="A5120-48P-EI-2",
description="HP Procurve A5120 V2",
sysobjectid=sysobjectid,
)

assert netbox_type.get_enterprise_id() is None

0 comments on commit 3756c1e

Please sign in to comment.