def test_selective_attribute_nd(self): nd = Nd(device=self.device) nd.maker.outputs[ShowIpv6NeighborDetail] = { "{'vrf':'all'}": NdOutput.showIpv6NeighborDetail } nd.maker.outputs[ShowIpv6NdInterface] = { "{'interface':'','vrf':'all'}": NdOutput.showIpv6NdInterface } nd.maker.outputs[ShowIpv6IcmpNeighborDetail] = { "{'interface':'','vrf':'all'}": NdOutput.showIpv6IcmpNeighborDetail } nd.maker.outputs[ShowIpv6Routers] = { "{'vrf':'all'}": NdOutput.showIpv6Routers } # Learn the feature nd.learn() # Check match self.assertEqual( 'other', nd.info['interfaces']['Ethernet1/1']['neighbors'] ['2001:db8:c56d:4::2']['origin']) # Check does not match self.assertNotEqual( 'static', nd.info['interfaces']['Ethernet1/1']['neighbors'] ['2001:db8:c56d:4::2']['origin'])
def test_missing_attributes_nd(self): f = Nd(device=self.device) f.maker.outputs[ShowIpv6NeighborDetail] = {"{'vrf':'all'}": NdOutput.showIpv6NeighborDetail} f.maker.outputs[ShowIpv6NdInterface] = {"{'vrf':'all'}": NdOutput.showIpv6NdInterface} f.maker.outputs[ShowIpv6IcmpNeighborDetail] = {"{'vrf':'all'}": NdOutput.showIpv6IcmpNeighborDetail} f.maker.outputs[ShowIpv6Routers] = {"{'vrf':'all'}": NdOutput.showIpv6Routers} # Learn the feature f.learn() with self.assertRaises(KeyError): interfaces = f.info['interfaces']['Etherenet1/1']['neighbors']['2010:2:3::2']
def test_full_nd(self): f = Nd(device=self.device) f.maker.outputs[ShowIpv6NeighborDetail] = {"{'vrf':'all'}": NdOutput.showIpv6NeighborDetail} f.maker.outputs[ShowIpv6NdInterface] = {"{'vrf':'all'}": NdOutput.showIpv6NdInterface} f.maker.outputs[ShowIpv6IcmpNeighborDetail] = {"{'vrf':'all'}": NdOutput.showIpv6IcmpNeighborDetail} f.maker.outputs[ShowIpv6Routers] = {"{'vrf':'all'}": NdOutput.showIpv6Routers} self.device.execute = Mock() # Learn the feature f.learn() self.maxDiff = None self.assertEqual(f.info, NdOutput.ndOpsOutput)
def test_empty_output_nd(self): self.maxDiff = None f = Nd(device=self.device) # Get outputs f.maker.outputs[ShowIpv6NeighborDetail] = {"{'vrf':'all'}": {}} f.maker.outputs[ShowIpv6NdInterface] = {"{'vrf':'all'}": {}} f.maker.outputs[ShowIpv6IcmpNeighborDetail] = {"{'vrf':'all'}": {}} f.maker.outputs[ShowIpv6Routers] = {"{'vrf':'all'}": {}} # Learn the feature f.learn() # Check no attribute not found with self.assertRaises(AttributeError): f.info['interfaces']
def test_full_nd(self): nd = Nd(device=self.device) nd.maker.outputs[ShowIpv6NeighborDetail] = { "{'vrf':'all'}": NdOutput.showIpv6NeighborDetail } nd.maker.outputs[ShowIpv6NdInterface] = { "{'interface':'','vrf':'all'}": NdOutput.showIpv6NdInterface } nd.maker.outputs[ShowIpv6IcmpNeighborDetail] = { "{'interface':'','vrf':'all'}": NdOutput.showIpv6IcmpNeighborDetail } nd.maker.outputs[ShowIpv6Routers] = { "{'vrf':'all'}": NdOutput.showIpv6Routers } # Learn the feature nd.learn() self.maxDiff = None self.assertEqual(nd.info, NdOutput.ndOpsOutput)
def test_missing_attributes_nd(self): nd = Nd(device=self.device) nd.maker.outputs[ShowIpv6NeighborDetail] = { "{'vrf':'all'}": NdOutput.showIpv6NeighborDetail } nd.maker.outputs[ShowIpv6NdInterface] = { "{'interface':'','vrf':'all'}": NdOutput.showIpv6NdInterface } nd.maker.outputs[ShowIpv6IcmpNeighborDetail] = { "{'interface':'','vrf':'all'}": NdOutput.showIpv6IcmpNeighborDetail } nd.maker.outputs[ShowIpv6Routers] = { "{'vrf':'all'}": NdOutput.showIpv6Routers } # Learn the feature nd.learn() with self.assertRaises(KeyError): interfaces = nd.info['interfaces']['Etherenet1/1']['neighbors'][ '2001:db8:c56d:4::2']
def test_custom_nd(self): nd = Nd(device=self.device) nd.maker.outputs[ShowIpv6NeighborDetail] = { "{'vrf':'VRF1'}": NdOutput.showIpv6NeighborDetail_custom } nd.maker.outputs[ShowIpv6NdInterface] = { "{'interface':'Ethernet1/2.420','vrf':'VRF1'}": NdOutput.showIpv6NdInterface_custom } nd.maker.outputs[ShowIpv6IcmpNeighborDetail] = { "{'interface':'Ethernet1/2.420','vrf':'VRF1'}": NdOutput.showIpv6IcmpNeighborDetail_custom } nd.maker.outputs[ShowIpv6Routers] = { "{'vrf':'VRF1'}": NdOutput.showIpv6Routers_custom } # Learn the feature nd.learn(vrf='VRF1', interface='Ethernet1/2.420') self.maxDiff = None self.assertEqual(nd.info, NdOutput.ndOpsOutput_custom)