Пример #1
0
    def test_empty_output(self):
        self.maxDiff = None
        prefix = PrefixList(device=self.device)
        # Get outputs
        prefix.maker.outputs[ShowIpPrefixListDetail] = {'': ''}

        prefix.maker.outputs[ShowIpv6PrefixListDetail] = {'': ''}

        # Learn the feature
        prefix.learn()

        # Check no attribute not found
        with self.assertRaises(AttributeError):
            out = prefix.info['prefix_set_name']
Пример #2
0
    def test_complete_output(self):
        self.maxDiff = None
        prefix = PrefixList(device=self.device)
        # Get outputs
        prefix.maker.outputs[ShowIpPrefixListDetail] = \
            {'':PrefixListOutput.ShowIpPrefixListDetail}

        prefix.maker.outputs[ShowIpv6PrefixListDetail] = \
            {'':PrefixListOutput.ShowIpv6PrefixListDetail}

        # Learn the feature
        prefix.learn()

        # Verify Ops was created successfully
        self.assertEqual(prefix.info, PrefixListOutput.PrefixList_info)
Пример #3
0
    def test_incomplete_output(self):
        self.maxDiff = None
        prefix = PrefixList(device=self.device)
        # Get outputs
        prefix.maker.outputs[ShowIpPrefixListDetail] = \
            {'':PrefixListOutput.ShowIpPrefixListDetail}

        prefix.maker.outputs[ShowIpv6PrefixListDetail] = {'': ''}

        # Learn the feature
        prefix.learn()

        # Delete missing specific attribute values
        expect_dict = deepcopy(PrefixListOutput.PrefixList_info)
        del (expect_dict['prefix_set_name']['test6'])

        # Verify Ops was created successfully
        self.assertEqual(prefix.info, expect_dict)
Пример #4
0
    def test_selective_attribute(self):
        self.maxDiff = None
        prefix = PrefixList(device=self.device)
        # Get outputs
        prefix.maker.outputs[ShowIpPrefixListDetail] = \
            {'':PrefixListOutput.ShowIpPrefixListDetail}

        prefix.maker.outputs[ShowIpv6PrefixListDetail] = \
            {'':PrefixListOutput.ShowIpv6PrefixListDetail}

        # Learn the feature
        prefix.learn()      

        # Check specific attribute values
        # info - protocol
        self.assertEqual(prefix.info['prefix_set_name']['test']['protocol'], 'ipv4')
        # info - ipv6 prefix
        self.assertEqual(prefix.info['prefix_set_name']['test6']['prefixes']\
                                  ['2001:DB8:2::/64 65..128 permit']['prefix'], '2001:DB8:2::/64')