forked from Uninett/nav
-
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.
Add tests for get enterprise id in NetboxType
- Loading branch information
1 parent
e0ef480
commit 3756c1e
Showing
1 changed file
with
43 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
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 |