Skip to content

Commit

Permalink
Add fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
stveit committed Aug 30, 2023
1 parent 83224bf commit 0f62c1a
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/unittests/portadmin/portadmin_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from mock import Mock

import unittest
import pytest

from nav.oids import OID
from nav.enterprise.ids import VENDOR_ID_HEWLETT_PACKARD, VENDOR_ID_CISCOSYSTEMS
Expand All @@ -10,6 +11,58 @@
from nav.portadmin.vlan import FantasyVlan


@pytest.fixture
def profile():
profile = Mock()
profile.snmp_version = 2
profile.snmp_community = "public"
return profile


@pytest.fixture
def netbox_hp(profile):
vendor = Mock()
vendor.id = u'hp'

netbox_type = Mock()
netbox_type.vendor = vendor
netbox_type.get_enterprise_id.return_value = VENDOR_ID_HEWLETT_PACKARD

netbox = Mock()
netbox.type = netbox_type
netbox.ip = '10.240.160.39'
netbox.get_preferred_snmp_management_profile.return_value = profile

return netbox


@pytest.fixture
def netbox_cisco(profile):
vendor = Mock()
vendor.id = u'cisco'

netbox_type = Mock()
netbox_type.vendor = vendor
netbox_type.get_enterprise_id.return_value = VENDOR_ID_CISCOSYSTEMS

netbox = Mock()
netbox.type = netbox_type
netbox.ip = '10.240.160.38'
netbox.get_preferred_snmp_management_profile.return_value = profile

return netbox


@pytest.fixture
def handler_hp(netbox_hp):
return ManagementFactory.get_instance(netbox_hp)


@pytest.fixture
def handler_cisco(netbox_cisco):
return ManagementFactory.get_instance(netbox_cisco)


class PortadminResponseTest(unittest.TestCase):
def setUp(self):
self.profile = Mock()
Expand Down

0 comments on commit 0f62c1a

Please sign in to comment.