Exemplo n.º 1
0
    def test_empty_output(self):
        self.maxDiff = None
        prefix = PrefixList(device=self.device)
        # Get outputs
        prefix.maker.outputs[ShowIpPrefixList] = {'': ''}

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

        # Learn the feature
        prefix.learn()

        # Check no attribute not found
        with self.assertRaises(AttributeError):
            out = prefix.info['prefix_set_name']
Exemplo n.º 2
0
    def test_complete_output(self):
        self.maxDiff = None
        prefix = PrefixList(device=self.device)
        # Get outputs
        prefix.maker.outputs[ShowIpPrefixList] = \
            {'':PrefixListOutput.ShowIpPrefixList}

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

        # Learn the feature
        prefix.learn()

        # Verify Ops was created successfully
        self.assertEqual(prefix.info, PrefixListOutput.PrefixList_info)
Exemplo n.º 3
0
    def test_incomplete_output(self):
        self.maxDiff = None
        prefix = PrefixList(device=self.device)
        # Get outputs
        prefix.maker.outputs[ShowIpPrefixList] = \
            {'':PrefixListOutput.ShowIpPrefixList}

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

        # 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)
Exemplo n.º 4
0
    def test_selective_attribute(self):
        self.maxDiff = None
        prefix = PrefixList(device=self.device)
        # Get outputs
        prefix.maker.outputs[ShowIpPrefixList] = \
            {'':PrefixListOutput.ShowIpPrefixList}

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

        # 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:3::/64 64..128 permit']['prefix'], '2001:db8:3::/64')