def setUp(self): repo = ContainerRepository() netbox = repo.factory(None, Netbox) netbox.id = 1 vlan = repo.factory('20', Vlan) for addr in ('2001:700:1::/64', '10.0.1.0/30', 'fe80::/64'): prefix = repo.factory(addr, Prefix) prefix.vlan = vlan prefix.net_address = addr self.vlan = vlan self.repo = repo
def test_empty_result_should_not_set_sysname(self): containers = ContainerRepository() netbox = containers.factory(None, Netbox) netbox.sysname = 'original-sw.example.org' netbox_in = Mock('NetBox') netbox_in.sysname = 'original-sw.example.org' netbox_in.ip = '127.0.0.1' plugin = DnsName(netbox_in, Mock('agent'), containers) plugin._verify_name_change(None) self.assertEquals(netbox.sysname, 'original-sw.example.org')
def setUp(self): repo = ContainerRepository() netbox = repo.factory(None, Netbox) netbox.id = 1 vlan = repo.factory('42', Vlan) self.shadow_prefixes = [] for addr in ('2001:700:1::/64', '10.0.42.0/31'): prefix = repo.factory(addr, Prefix) prefix.vlan = vlan prefix.net_address = addr self.shadow_prefixes.append(prefix) self.vlan = vlan self.repo = repo
def test_ifalias_should_be_unicode(self): netbox = Mock('Netbox') agent = Mock('AgentProxy') containers = ContainerRepository() plugin = Interfaces(netbox, agent, containers, FakeConfig()) row = { 'ifDescr': 'GigabitEthernet0/1', 'ifName': 'Gi0/1', 'ifAlias': 'The Larch', } required_keys = ( 'ifType', 'ifSpeed', 'ifSpeed', 'ifHighSpeed', 'ifAdminStatus', 'ifOperStatus', 'ifPhysAddress', 'ifConnectorPresent', ) for k in required_keys: row[k] = None interface = plugin._convert_row_to_container(netbox, 1, row) self.assertTrue(isinstance(interface.ifalias, str))
def test_make_new_mappings_should_not_raise_on_empty_ip(): a = Arp(None, None, ContainerRepository()) mappings = [(None, '00:0b:ad:c0:ff:ee')] a._make_new_mappings(mappings)
def test_non_ascii_chassis_id_should_not_crash(): record = Mock(chassid_id='a\x9enon-ascii') plugin = LLDP(None, None, ContainerRepository()) plugin._store_unidentified(record)