示例#1
0
    def test_incomplete_output(self):
        self.maxDiff = None

        igmp = Igmp(device=self.device)

        # Get outputs
        igmp.maker.outputs[ShowVrfDetail] = \
            {'': IgmpOutput.ShowVrfDetail}

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

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

        # Learn the feature
        igmp.learn()

        # Delete missing specific attribute values
        expect_dict = deepcopy(IgmpOutput.Igmp_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(igmp.info, expect_dict)
示例#2
0
    def test_complete_output(self):
        self.maxDiff = None
        igmp = Igmp(device=self.device)
        # Get outputs
        igmp.maker.outputs[ShowVrfDetail] = \
            {'': IgmpOutput.ShowVrfDetail}

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

        # Learn the feature
        igmp.learn()

        # Verify Ops was created successfully
        self.assertEqual(igmp.info, IgmpOutput.Igmp_info)
示例#3
0
    def test_selective_attribute(self):
        self.maxDiff = None
        igmp = Igmp(device=self.device)
        # Get outputs
        igmp.maker.outputs[ShowVrfDetail] = \
            {'': IgmpOutput.ShowVrfDetail}

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

        # Learn the feature
        igmp.learn()

        # Check specific attribute values
        # info - default vrf
        self.assertEqual(igmp.info['vrfs']['default']['max_groups'], 20)
        # info - vrf VRF1
        self.assertEqual(igmp.info['vrfs']['VRF1']['interfaces']\
                                  ['GigabitEthernet2']['querier'], '10.186.2.1')
示例#4
0
    def test_empty_output(self):
        self.maxDiff = None
        igmp = Igmp(device=self.device)
        # Get outputs
        igmp.maker.outputs[ShowVrfDetail] = \
            {'': {}}

        # Return outputs above as inputs to parser when called
        self.device.execute = Mock()
        outputs['show ip igmp interface'] = ''
        outputs['show ip igmp vrf VRF1 interface'] = ''
        outputs['show ip igmp groups detail'] = ''
        outputs['show ip igmp vrf VRF1 groups detail'] = ''
        outputs['show ip igmp ssm-mapping 239.1.1.1'] = ''
        outputs['show ip igmp vrf VRF1 ssm-mapping 239.1.1.1'] = ''
        self.device.execute.side_effect = mapper

        # Learn the feature
        igmp.learn()

        # revert the outputs
        outputs[
            'show ip igmp interface'] = IgmpOutput.ShowIpIgmpInterface_default
        outputs[
            'show ip igmp vrf VRF1 interface'] = IgmpOutput.ShowIpIgmpInterface_VRF1
        outputs[
            'show ip igmp groups detail'] = IgmpOutput.ShowIpIgmpGroupsDetail_default
        outputs[
            'show ip igmp vrf VRF1 groups detail'] = IgmpOutput.ShowIpIgmpGroupsDetail_VRF1
        outputs[
            'show ip igmp ssm-mapping 239.1.1.1'] = IgmpOutput.ShowIpIgmpSsmMapping_default_1
        outputs[
            'show ip igmp vrf VRF1 ssm-mapping 239.1.1.1'] = IgmpOutput.ShowIpIgmpSsmMapping_VRF1_1

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