def test_ignored(self): f = RoutePolicy(device=self.device) g = RoutePolicy(device=self.device) f.maker.outputs[ShowRouteMapAll] = \ {'':RoutePolicyOutput.showRouteMapAll} g.maker.outputs[ShowRouteMapAll] = \ {'':RoutePolicyOutput.showRouteMapAll} f.learn() g.learn() f.diff_ignore.append( 'info[test][statements][10][actions][set_route_origin][origin]') self.assertNotEqual(f, g) # Verify diff now diff = f.diff(g) sorted_diff = str(diff) sorted_result = ( '''+diff_ignore: deque(['maker', 'callables', 'device', 'info[test][statements][10][actions][set_route_origin][origin]'])\n-diff_ignore: deque(['maker', 'callables', 'device'])''' ) self.assertEqual(sorted_diff, sorted_result)
def test_missing_attributes(self): f = RoutePolicy(device=self.device) f.maker.outputs[ShowRouteMapAll] = \ {'':RoutePolicyOutput.showRouteMapAll} f.learn() with self.assertRaises(KeyError): vlan_access_map_value=(f.info['test']['statements']\ ['20']['actions']['clause']['True'])
def test_sample(self): f = RoutePolicy(device=self.device) f.maker.outputs[ShowRouteMapAll] = \ {'':RoutePolicyOutput.showRouteMapAll} f.learn() self.assertEqual(f.info, RoutePolicyOutput.RoutePolicy['info'])
def test_selective_attribute(self): f = RoutePolicy(device=self.device, attributes=['info[(.*)][statements]']) f.maker.outputs[ShowRouteMapAll] = \ {'':RoutePolicyOutput.showRouteMapAll} f.learn() self.assertIn('10', f.info['test']['statements']) self.assertNotIn('20', f.info['test']['statements'])
def test_ignored(self): f = RoutePolicy(device=self.device) g = RoutePolicy(device=self.device) f.maker.outputs[ShowRouteMapAll] = \ {'':RoutePolicyOutput.showRouteMapAll} g.maker.outputs[ShowRouteMapAll] = \ {'':RoutePolicyOutput.showRouteMapAll} f.learn() g.learn() f.s = 2 self.assertNotEqual(f,g) # Verify diff now diff = f.diff(g) sorted_diff = str(diff) sorted_result = ('+s: 2') self.assertEqual(sorted_diff,sorted_result)