def test_complete_output(self): mcast = Mcast(device=self.device) # Set outputs mcast.maker.outputs[ShowVrfDetail] = {'': McastOutput.ShowVrfDetail} self.device.execute = Mock() self.device.execute.side_effect = mapper # Learn the feature mcast.learn() self.maxDiff = None # Verify Ops was created successfully self.assertEqual(mcast.info, McastOutput.McastInfo) self.assertEqual(mcast.table, McastOutput.McastTable)
def test_selective_attribute(self): mcast = Mcast(device=self.device) # Set outputs mcast.maker.outputs[ShowVrfDetail] = {'': McastOutput.ShowVrfDetail} self.device.execute = Mock() self.device.execute.side_effect = mapper # Learn the feature mcast.learn() # Test specific attributes in info self.assertEqual(mcast.info['vrf']['default']['address_family']['ipv4']\ ['mroute']['172.16.0.0/16']['path']['172.30.10.13 1']\ ['neighbor_address'], '172.30.10.13') # Test specific attribute in table self.assertEqual(mcast.table['vrf']['VRF1']['address_family']\ ['ipv6']['multicast_group']['FF07::1']\ ['source_address']['2001:DB8:999::99']['flags'], 'SFT')
def test_empty_output(self): mcast = Mcast(device=self.device) # Set outputs mcast.maker.outputs[ShowVrfDetail] = {'':McastOutput.ShowVrfDetail} self.device.execute = Mock() self.device.execute.side_effect = ['','','','','','','','','','','',''] # Learn the feature mcast.learn() # Check no outputs in mcast.info with self.assertRaises(AttributeError): neighbor_address = mcast.info['vrf']['default']['address_family']['ipv4']\ ['mroute']['172.16.0.0/16']['path']['172.30.10.13 1']\ ['neighbor_address'] # Check no outputs in mcast.table with self.assertRaises(AttributeError): flags = mcast.table['vrf']['VRF1']['address_family']\ ['ipv6']['multicast_group']['FF07::1']\ ['source_address']['2001:DB8:999::99']['flags']
def test_incomplete_output(self): mcast = Mcast(device=self.device) # Set outputs mcast.maker.outputs[ShowVrfDetail] = {'':McastOutput.ShowVrfDetail} self.device.execute = Mock() outputs['show ip multicast'] = '' self.device.execute.side_effect = mapper # Learn the feature mcast.learn() # Delete missing specific attribute values expect_dict = deepcopy(McastOutput.McastInfo) del(expect_dict['vrf']['default']['address_family']['ipv4']['enable']) del(expect_dict['vrf']['default']['address_family']['ipv4']['multipath']) # Verify Ops was created successfully self.assertEqual(mcast.info, expect_dict) self.assertEqual(mcast.table, McastOutput.McastTable)