コード例 #1
0
    def test_empty_output_route(self):
        self.maxDiff = None
        f = Routing(device=self.device)

        outputs['show route ipv4'] = ''
        outputs['show route vrf all ipv4'] = ''
        outputs['show route ipv6'] = ''
        outputs['show route vrf all ipv6'] = ''
        outputs['show route ipv4 10.23.90.0'] = ''
        outputs['show route vrf all ipv4 10.23.90.0'] = ''
        # Get outputs
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper

        # Learn the feature
        f.learn()
        self.maxDiff = None
        outputs['show route ipv4'] = RoutingOutput.showRouteIpv4
        outputs['show route vrf all ipv4'] = RoutingOutput.showRouteVrfAllIpv4
        outputs['show route ipv6'] = RoutingOutput.showRouteIpv6
        outputs['show route vrf all ipv6'] = RoutingOutput.showRouteVrfAllIpv6
        outputs[
            'show route ipv4 10.23.90.0'] = RoutingOutput.showRouteIpv4_route
        outputs[
            'show route vrf all ipv4 10.23.90.0'] = RoutingOutput.showRouteVrfAllIpv4_route
        # Check no attribute not found
        with self.assertRaises(AttributeError):
            f.info['vrf']
コード例 #2
0
 def test_full_route(self):
     f = Routing(device=self.device)
     # Get 'show ip static route' output
     self.device.execute = Mock()
     self.device.execute.side_effect = mapper
     # Learn the feature
     f.learn()
     self.maxDiff = None
     self.assertEqual(f.info, RoutingOutput.showRouteOpsOutput)
コード例 #3
0
 def test_full_route(self):
     f = Routing(device=self.device)
     # Get 'show ip static route' output
     f.maker.outputs[ShowRouteIpv4] = {'': RoutingOutput.showRouteIpv4}
     f.maker.outputs[ShowRouteIpv6] = {'': RoutingOutput.showRouteIpv6}
     self.device.execute = Mock()
     # Learn the feature
     f.learn()
     self.maxDiff = None
     self.assertEqual(f.info, RoutingOutput.showRouteOpsOutput)
コード例 #4
0
 def test_custom_output(self):
     f = Routing(device=self.device)
     # Get 'show ip static route' output
     self.device.execute = Mock()
     self.device.execute.side_effect = mapper
     # Learn the feature
     f.learn(address_family='ipv4',
             route='10.23.90.0',
             interface='GigabitEthernet0/0/0/1.90')
     self.maxDiff = None
     self.assertEqual(f.info, RoutingOutput.showRouteOpsOutput_custom)
コード例 #5
0
    def test_missing_attributes_route(self):
        f = Routing(device=self.device)
        f.maker.outputs[ShowRouteIpv4] = {'': RoutingOutput.showRouteIpv4}
        f.maker.outputs[ShowRouteIpv6] = {'': RoutingOutput.showRouteIpv6}

        # Learn the feature
        f.learn()

        with self.assertRaises(KeyError):
            interfaces = f.info['vrf']['VRF1']['address_family']['ipv4']['routes']\
                ['1.1.1.1/32']['next_hop']['next_hop_vrf']
コード例 #6
0
    def test_selective_attribute_route(self):
        f = Routing(device=self.device)

        # Get 'show ipv4 static route' output
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper
        # Learn the feature
        f.learn()
        # Check match
        self.maxDiff = None
        self.assertEqual('2001:10:23:120::2/128', f.info['vrf']['default']['address_family']['ipv6']['routes']\
            ['2001:10:23:120::2/128']['route'])
コード例 #7
0
    def test_empty_output_route(self):
        self.maxDiff = None
        f = Routing(device=self.device)

        # Get outputs
        f.maker.outputs[ShowRouteIpv4] = {'': {}}
        f.maker.outputs[ShowRouteIpv6] = {'': {}}

        # Learn the feature
        f.learn()

        # Check no attribute not found
        with self.assertRaises(AttributeError):
            f.info['vrf']
コード例 #8
0
    def test_selective_attribute_route(self):
        f = Routing(device=self.device)

        # Get 'show ipv4 static route' output
        f.maker.outputs[ShowRouteIpv4] = {'': RoutingOutput.showRouteIpv4}
        f.maker.outputs[ShowRouteIpv6] = {'': RoutingOutput.showRouteIpv6}
        # Learn the feature
        f.learn()
        # Check match

        self.assertEqual('2001:1:1:1::1/128', f.info['vrf']['default']['address_family']['ipv6']['routes']\
            ['2001:1:1:1::1/128']['route'])
        # Check does not match
        self.assertNotEqual(5, f.info['vrf']['default']['address_family']['ipv6']['routes']\
            ['2001:1:1:1::1/128']['next_hop']['next_hop_list'][1]['index'])