示例#1
0
    def test_output_with_attribute(self):
        self.maxDiff = None
        arp = Arp(device=self.device, attributes=['info[statistics][(.*)]'])

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

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

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

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

        # 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'])
示例#2
0
    def test_complete_output(self):
        self.maxDiff = None
        arp = Arp(device=self.device)

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

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

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

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

        # 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']['Ethernet1/4.200']['ipv4']\
            ['neighbors']['55.1.1.101']['ip'], '55.1.1.101')
        # info - statistics
        self.assertEqual(arp.info['statistics']['in_drops'], 28218)
示例#3
0
    def test_empty_output(self):
        self.maxDiff = None
        arp = Arp(device=self.device)

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

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

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

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

        # Learn the feature
        arp.learn()

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