Esempio n. 1
0
    def test_selective_attribute(self):
        self.maxDiff = None
        mld = Mld(device=self.device)
        # Get outputs
        mld.maker.outputs[ShowVrfDetail] = \
            {'': MldOutput.ShowVrfDetail}

        mld.maker.outputs[ShowIpv6MldInterface] = \
            {"{'vrf':''}": MldOutput.ShowIpv6MldInterface_default}

        mld.maker.outputs[ShowIpv6MldGroupsDetail] = \
            {"{'vrf':''}": MldOutput.ShowIpv6MldGroupsDetail_default}

        # Return outputs above as inputs to parser when called
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper

        # Learn the feature
        mld.learn()

        # Check specific attribute values
        # info - default vrf
        self.assertEqual(mld.info['vrfs']['default']['max_groups'], 64000)
        # info - vrf VRF1
        self.assertEqual(mld.info['vrfs']['VRF1']['interfaces']\
                                  ['GigabitEthernet2']['querier'], 'FE80::5054:FF:FEDD:BB49')
Esempio n. 2
0
    def test_incomplete_output(self):
        self.maxDiff = None

        mld = Mld(device=self.device)

        # Get outputs
        mld.maker.outputs[ShowVrfDetail] = \
            {'': MldOutput.ShowVrfDetail}

        mld.maker.outputs[ShowIpv6MldInterface] = \
            {"{'vrf':''}": MldOutput.ShowIpv6MldInterface_default}

        mld.maker.outputs[ShowIpv6MldGroupsDetail] = \
            {"{'vrf':''}": MldOutput.ShowIpv6MldGroupsDetail_default}

        # Return outputs above as inputs to parser when called
        self.device.execute = Mock()

        # overwrite output with empty output
        outputs['show ipv6 mld vrf VRF1 groups detail'] = ''
        self.device.execute.side_effect = mapper

        # Learn the feature
        mld.learn()

        # revert the outputs
        outputs[
            'show ipv6 mld vrf VRF1 groups detail'] = MldOutput.ShowIpv6MldGroupsDetail_VRF1

        # Delete missing specific attribute values
        expect_dict = deepcopy(MldOutput.Mld_info)
        del (expect_dict['vrfs']['VRF1']['interfaces']['GigabitEthernet2']
             ['join_group'])
        del (expect_dict['vrfs']['VRF1']['interfaces']['GigabitEthernet2']
             ['static_group'])
        del (expect_dict['vrfs']['VRF1']['interfaces']['GigabitEthernet2']
             ['group'])
        del (expect_dict['vrfs']['VRF1']['ssm_map'])

        # Verify Ops was created successfully
        self.assertEqual(mld.info, expect_dict)
Esempio n. 3
0
    def test_complete_output(self):
        self.maxDiff = None
        mld = Mld(device=self.device)
        # Get outputs
        mld.maker.outputs[ShowVrfDetail] = \
            {'': MldOutput.ShowVrfDetail}

        mld.maker.outputs[ShowIpv6MldInterface] = \
            {"{'vrf':''}": MldOutput.ShowIpv6MldInterface_default}

        mld.maker.outputs[ShowIpv6MldGroupsDetail] = \
            {"{'vrf':''}": MldOutput.ShowIpv6MldGroupsDetail_default}

        # Return outputs above as inputs to parser when called
        self.device.execute = Mock()
        self.device.execute.side_effect = mapper

        # Learn the feature
        mld.learn()

        # Verify Ops was created successfully
        self.assertEqual(mld.info, MldOutput.Mld_info)
Esempio n. 4
0
    def test_empty_output(self):
        self.maxDiff = None
        mld = Mld(device=self.device)
        # Get outputs
        mld.maker.outputs[ShowVrfDetail] = \
            {'': {}}

        mld.maker.outputs[ShowIpv6MldInterface] = \
            {"{'vrf':''}": {}}

        mld.maker.outputs[ShowIpv6MldGroupsDetail] = \
            {"{'vrf':''}": {}}

        # Return outputs above as inputs to parser when called
        self.device.execute = Mock()
        outputs['show ipv6 mld vrf VRF1 interface'] = ''
        outputs['show ipv6 mld vrf VRF1 groups detail'] = ''
        outputs['show ipv6 mld ssm-map FF35:1::1'] = ''
        outputs['show ipv6 mld vrf VRF1 ssm-map FF35:1::1'] = ''
        self.device.execute.side_effect = mapper

        # Learn the feature
        mld.learn()

        # revert the outputs
        outputs[
            'show ipv6 mld vrf VRF1 interface'] = MldOutput.ShowIpv6MldInterface_VRF1
        outputs[
            'show ipv6 mld vrf VRF1 groups detail'] = MldOutput.ShowIpv6MldGroupsDetail_VRF1
        outputs[
            'show ipv6 mld ssm-map FF35:1::1'] = MldOutput.ShowIpv6MldSsmMap_default_3
        outputs[
            'show ipv6 mld vrf VRF1 ssm-map FF35:1::1'] = MldOutput.ShowIpv6MldSsmMap_VRF1_3

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