Example #1
0
    def test_complete_output(self):
        self.maxDiff = None
        arp = Arp(device=self.device)

        # Get outputs
        arp.maker.outputs[ShowArpDetail] = \
            {"": ArpOutput.ShowArpDetail}

        arp.maker.outputs[ShowArpTrafficDetail] = \
            {"": ArpOutput.ShowArpTrafficDetail}

        arp.maker.outputs[ShowIpv4VrfAllInterface] = \
            {"": ArpOutput.ShowIpv4VrfAllInterface}

        # Learn the feature
        arp.learn()

        # Verify Ops was created successfully
        self.assertEqual(arp.info, ArpOutput.Arp_info)

        # Check specific attribute values
        # info - interfaces
        self.assertEqual(arp.info['interfaces']['GigabitEthernet0/0/0/0']\
            ['ipv4']['neighbors']['10.1.2.1']['ip'], '10.1.2.1')
        # info - statistics
        self.assertEqual(arp.info['statistics']['in_replies_pkts'], 8)
Example #2
0
    def test_empty_output(self):
        self.maxDiff = None
        arp = Arp(device=self.device)

        # Get outputs
        arp.maker.outputs[ShowArpDetail] = \
            {"": {}}

        arp.maker.outputs[ShowArpTrafficDetail] = \
            {"": {}}

        arp.maker.outputs[ShowIpv4VrfAllInterface] = \
            {"": {}}

        # Learn the feature
        arp.learn()

        # Check no attribute not found
        with self.assertRaises(AttributeError):
            arp.info['statistics']
Example #3
0
    def test_output_with_attribute(self):
        self.maxDiff = None
        arp = Arp(device=self.device, attributes=['info[statistics][(.*)]'])

        # Get outputs
        arp.maker.outputs[ShowArpDetail] = \
            {"": ArpOutput.ShowArpDetail}

        arp.maker.outputs[ShowArpTrafficDetail] = \
            {"": ArpOutput.ShowArpTrafficDetail}

        arp.maker.outputs[ShowIpv4VrfAllInterface] = \
            {"": ArpOutput.ShowIpv4VrfAllInterface}

        # Learn the feature
        arp.learn()

        # Check no attribute not found
        with self.assertRaises(KeyError):
            arp.info['interfaces']

        # info - statistics
        self.assertEqual(arp.info['statistics'],
                         ArpOutput.Arp_info['statistics'])